From 23e4b1163c08351ec3bcd00bf11b6702d30419cf Mon Sep 17 00:00:00 2001 From: aj-rosado <109146700+aj-rosado@users.noreply.github.com> Date: Fri, 7 Nov 2025 17:14:48 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=92=20[PM-27902]=20Logout=20user=20aft?= =?UTF-8?q?er=20successful=20master=20password=20reset=20(#6137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/auth/repository/AuthRepositoryImpl.kt | 10 ++++------ .../data/auth/repository/model/LogoutReason.kt | 5 +++++ .../data/auth/repository/AuthRepositoryTest.kt | 6 ++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index f2b8559bc7..73c0680bcf 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -1023,12 +1023,6 @@ class AuthRepositoryImpl( } .fold( onSuccess = { - // Clear the password reset reason, since it's no longer relevant. - storeUserResetPasswordReason( - userId = activeAccount.profile.userId, - reason = null, - ) - // Update the saved master password hash. authSdkSource .hashPassword( @@ -1044,6 +1038,10 @@ class AuthRepositoryImpl( ) } + // Log out the user after successful password reset. + // This clears all user state including forcePasswordResetReason. + logout(reason = LogoutReason.PasswordReset) + // Return the success. ResetPasswordResult.Success }, diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/model/LogoutReason.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/model/LogoutReason.kt index 473fed3144..b2ca662e41 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/model/LogoutReason.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/model/LogoutReason.kt @@ -66,6 +66,11 @@ sealed class LogoutReason { */ data object Notification : LogoutReason() + /** + * Indicates that the logout is happening because the user reset their master password. + */ + data object PasswordReset : LogoutReason() + /** * Indicates that the logout is happening because the sync security stamp was invalidated. */ diff --git a/app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index cb9cf467c7..21914ed33d 100644 --- a/app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -5073,6 +5073,12 @@ class AuthRepositoryTest { userId = USER_ID_1, passwordHash = newPasswordHash, ) + verify { + userLogoutManager.logout( + userId = ACCOUNT_1.profile.userId, + reason = LogoutReason.PasswordReset, + ) + } } @Test