apiConfigured method
Future<bool>
apiConfigured()
Checks if the API is configured by verifying the presence of user, password, and clientIdentifier in secure storage.
Returns true if all values are present and credentials are set successfully,
otherwise returns false.
This method also reapplies persisted group keys, which makes it the recommended session-restore call during app startup.
Implementation
Future<bool> apiConfigured() async {
final user = await getValueFromSecureStorage(
key: 'user',
);
final password = await getValueFromSecureStorage(
key: 'password',
);
final clientIdentifier = await getValueFromSecureStorage(
key: 'clientIdentifier',
);
if (user == null || password == null || clientIdentifier == null) {
return false;
}
final response = await setCredentials(
user: user,
password: password,
clientIdentifier: int.parse(clientIdentifier),
);
if (response.isLeft()) {
return false;
}
final groupRestoreResponse = await _restoreStoredGroupKeys();
if (groupRestoreResponse.isLeft()) {
return false;
}
return response.asRight;
}