Skip to content

Commit

Permalink
Asks enabling biometric authentication although I already enabled it …
Browse files Browse the repository at this point in the history
…previously (#1361)

* remove biometricAuthStateKey from AppService

* Fixed CI test

* Fixed typo

* [login_service] migrate biometricAuthState to new version

---------

Co-authored-by: clangenb <37865735+clangenb@users.noreply.github.com>
  • Loading branch information
Eldar2021 and clangenb authored Jul 15, 2023
1 parent f144345 commit e610d63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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' : '';
}

0 comments on commit e610d63

Please sign in to comment.