feat(mobile): Removed stay logged in checkbox and made it enabled by default (#1550)

* removed stay logged in checkbox and made it enabled by default

* adds padding to login button

* removed all isSaveLogin

* fix: logout would re-login with previous credential upon app restart

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
martyfuhry 2023-02-05 09:07:02 -05:00 committed by GitHub
parent f38c7a4b7e
commit 16183791f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 77 deletions

View file

@ -55,7 +55,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
String email,
String password,
String serverUrl,
bool isSavedLoginInfo,
) async {
try {
// Resolve API server endpoint from user provided serverUrl
@ -83,7 +82,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
return setSuccessLoginInfo(
accessToken: loginResponse.accessToken,
serverUrl: serverUrl,
isSavedLoginInfo: isSavedLoginInfo,
);
} catch (e) {
HapticFeedback.vibrate();
@ -100,21 +98,9 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
_assetCacheService.invalidate(),
_albumCacheService.invalidate(),
_sharedAlbumCacheService.invalidate(),
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).delete(savedLoginInfoKey)
]);
// Remove login info from local storage
var loginInfo =
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).get(savedLoginInfoKey);
if (loginInfo != null) {
loginInfo.email = "";
loginInfo.password = "";
loginInfo.isSaveLogin = false;
await Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).put(
savedLoginInfoKey,
loginInfo,
);
}
return true;
}
@ -156,7 +142,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
Future<bool> setSuccessLoginInfo({
required String accessToken,
required String serverUrl,
required bool isSavedLoginInfo,
}) async {
_apiService.setAccessToken(accessToken);
var userResponseDto = await _apiService.userApi.getMyUserInfo();
@ -181,22 +166,16 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
deviceType: deviceInfo["deviceType"],
);
if (isSavedLoginInfo) {
// Save login info to local storage
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).put(
savedLoginInfoKey,
HiveSavedLoginInfo(
email: "",
password: "",
isSaveLogin: true,
serverUrl: serverUrl,
accessToken: accessToken,
),
);
} else {
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox)
.delete(savedLoginInfoKey);
}
// Save login info to local storage
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).put(
savedLoginInfoKey,
HiveSavedLoginInfo(
email: "",
password: "",
serverUrl: serverUrl,
accessToken: accessToken,
),
);
}
// Register device info