Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ask for biometric authentication again after updating #1361

Merged
merged 5 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/lib/modules/login/service/login_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,29 @@ final class LoginService {

static const isDeviceSupportKey = 'is-device-support-key';
static const biometricAuthStateKey = 'biometric-auth-state';
static const oldBiometricAuthStateKey = 'biometric-auth-enabled';
static const pinStorageKey = 'pin-key';

BiometricAuthState? get getBiometricAuthState {
final biometricAuthState = preferences.getString(biometricAuthStateKey);
return biometricAuthState != null ? BiometricAuthState.fromString(biometricAuthState) : null;
if (biometricAuthState != null) return BiometricAuthState.fromString(biometricAuthState);

// See if we had set a state in earlier app versions
final biometricAuthenticationEnabledOld = preferences.getBool(oldBiometricAuthStateKey);
if (biometricAuthenticationEnabledOld == null) return null;

// migrate old storage to new one and return state
final biometricAuthStateOld = switch (biometricAuthenticationEnabledOld) {
true => BiometricAuthState.enabled,
false => BiometricAuthState.disabled,
};

// migrate the old storage to the new one
setBiometricAuthState(biometricAuthStateOld);
// clear the old storage
preferences.remove(oldBiometricAuthStateKey);

return biometricAuthStateOld;
}

Future<void> setBiometricAuthState(BiometricAuthState biometricAuthState) async {
Expand Down
3 changes: 0 additions & 3 deletions app/lib/modules/settings/service/app_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class AppService {
final SharedPreferences storage;

static const localStorageLocaleKey = 'locale';
static const biometricAuthStateKey = 'biometric-auth-state';

Locale get getLocale {
final code = storage.getString(localStorageLocaleKey);
Expand All @@ -24,6 +23,4 @@ class AppService {
await storage.setString(localStorageLocaleKey, languageCode);
return Locale(languageCode);
}

String? get getBiometricAuthState => storage.getString(biometricAuthStateKey);
}
2 changes: 1 addition & 1 deletion app/test_driver/helpers/command/app_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ String toggleDeveloperMode(AppSettings appSettings, bool devMode) {
}

String getBiometricAuthState(AppService appService) {
return appService.getBiometricAuthState ?? '';
return Platform.isAndroid ? 'Device not supported' : '';
}
Loading