mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	Added mechanism of required password change of new user's first login (#272)
* Deprecate login scenarios that support pre-web era * refactor and simplify setup * Added user info to change password form * change isFistLogin column to shouldChangePassword * Implemented change user password * Implement the change password page for mobile * Change label * Added changes log and up minor version * Fixed typo in the release note * Up server version
This commit is contained in:
		@@ -24,7 +24,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
 | 
			
		||||
            lastName: '',
 | 
			
		||||
            profileImagePath: '',
 | 
			
		||||
            isAdmin: false,
 | 
			
		||||
            isFirstLogin: false,
 | 
			
		||||
            shouldChangePassword: false,
 | 
			
		||||
            isAuthenticated: false,
 | 
			
		||||
            deviceInfo: DeviceInfoRemote(
 | 
			
		||||
              id: 0,
 | 
			
		||||
@@ -87,7 +87,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
 | 
			
		||||
        lastName: payload.lastName,
 | 
			
		||||
        profileImagePath: payload.profileImagePath,
 | 
			
		||||
        isAdmin: payload.isAdmin,
 | 
			
		||||
        isFirstLoggedIn: payload.isFirstLogin,
 | 
			
		||||
        shouldChangePassword: payload.shouldChangePassword,
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if (isSavedLoginInfo) {
 | 
			
		||||
@@ -111,8 +111,12 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
 | 
			
		||||
    // Register device info
 | 
			
		||||
    try {
 | 
			
		||||
      Response res = await _networkService.postRequest(
 | 
			
		||||
          url: 'device-info',
 | 
			
		||||
          data: {'deviceId': state.deviceId, 'deviceType': state.deviceType});
 | 
			
		||||
        url: 'device-info',
 | 
			
		||||
        data: {
 | 
			
		||||
          'deviceId': state.deviceId,
 | 
			
		||||
          'deviceType': state.deviceType,
 | 
			
		||||
        },
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      DeviceInfoRemote deviceInfo = DeviceInfoRemote.fromJson(res.toString());
 | 
			
		||||
      state = state.copyWith(deviceInfo: deviceInfo);
 | 
			
		||||
@@ -133,7 +137,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
 | 
			
		||||
      firstName: '',
 | 
			
		||||
      lastName: '',
 | 
			
		||||
      profileImagePath: '',
 | 
			
		||||
      isFirstLogin: false,
 | 
			
		||||
      shouldChangePassword: false,
 | 
			
		||||
      isAuthenticated: false,
 | 
			
		||||
      isAdmin: false,
 | 
			
		||||
      deviceInfo: DeviceInfoRemote(
 | 
			
		||||
@@ -163,6 +167,24 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
 | 
			
		||||
  updateUserProfileImagePath(String path) {
 | 
			
		||||
    state = state.copyWith(profileImagePath: path);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<bool> changePassword(String newPassword) async {
 | 
			
		||||
    Response res = await _networkService.putRequest(
 | 
			
		||||
      url: 'user',
 | 
			
		||||
      data: {
 | 
			
		||||
        'id': state.userId,
 | 
			
		||||
        'password': newPassword,
 | 
			
		||||
        'shouldChangePassword': false,
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (res.statusCode == 200) {
 | 
			
		||||
      state = state.copyWith(shouldChangePassword: false);
 | 
			
		||||
      return true;
 | 
			
		||||
    } else {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
final authenticationProvider =
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user