localLogin method
Implementation
Future<bool> localLogin() async {
var localAuth = LocalAuthentication();
bool canCheckBiometrics = await localAuth.canCheckBiometrics;
await _setLocalAuthType(localAuth);
_hasLocalAuth = canCheckBiometrics && _localAuthType != null;
if (_hasLocalAuth!) {
var storage = new FlutterSecureStorage();
var localLoginString = await storage.read(key: 'localLoginEnabled');
var localLoginInitialisedString =
await storage.read(key: 'localLoginInitialised');
_localLoginUid = await storage.read(key: 'localLoginUid');
_localLoginEnabled =
localLoginString != null && localLoginString.toLowerCase() == 'true';
_localLoginInitialised = localLoginInitialisedString != null &&
localLoginInitialisedString.toLowerCase() == 'true';
if (_localLoginEnabled && _localLoginInitialised) {
bool authenticated = await localAuth.authenticate(
//TODO fix this biometricOnly: true,
localizedReason:
'Please authenticate to login to ' + _mojo.appTitle());
if (authenticated) {
return true;
} else {
return false;
}
}
}
return false;
//check localLogin, if no or null, process to username/password, if yes, prompt with popup
//username/password login
//check localLogin, if null, show dialog would you like to use touch id/fingerprint/faceid
//if no, set localLogin to 'no' in storage, proceed to dashboard
//if yes, save localLogin yes, email/pass to storage, attempt app reset
}