user property
Future<CarpUser?>
user
The currently signed in user.
If a user is already autheticated to the CarpService
, then this account
is used for uploading the data to CARP.
If the user is not authenticated, this method will try to authenticate the user based on the configuration (uri, client_id, client_secret) and credentials (username and password) specified in carpEndPoint.
Implementation
Future<CarpUser?> get user async {
// check if the CARP webservice has already been configured and the user is logged in.
if (!CarpService().authenticated) {
info('$runtimeType - No user is authenticated. '
'Trying to authenticate based on configuration and credentials specified in the carpEndPoint.');
if (!CarpService().isConfigured) {
CarpService().configure(CarpApp(
studyDeploymentId: studyDeploymentId,
name: carpEndPoint.name,
uri: Uri.parse(carpEndPoint.uri.toString()),
oauth: OAuthEndPoint(
clientID: carpEndPoint.clientId.toString(),
clientSecret: carpEndPoint.clientSecret.toString()),
));
}
await CarpService().authenticate(
username: carpEndPoint.email.toString(),
password: carpEndPoint.password.toString(),
);
info("CarpDataManager - signed in user: ${CarpService().currentUser}");
}
return CarpService().currentUser;
}