mirror of
https://github.com/bitwarden/android.git
synced 2026-02-03 18:17:54 -06:00
PM-31603: Add toast when resetpassword succeeds (#6465)
This commit is contained in:
parent
365067e5be
commit
0811d14606
@ -5,6 +5,7 @@ import com.bitwarden.core.InitUserCryptoMethod
|
||||
import com.bitwarden.core.RegisterTdeKeyResponse
|
||||
import com.bitwarden.core.WrappedAccountCryptographicState
|
||||
import com.bitwarden.core.data.manager.dispatcher.DispatcherManager
|
||||
import com.bitwarden.core.data.manager.toast.ToastManager
|
||||
import com.bitwarden.core.data.repository.error.MissingPropertyException
|
||||
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
|
||||
import com.bitwarden.core.data.util.asFailure
|
||||
@ -47,6 +48,7 @@ import com.bitwarden.network.service.HaveIBeenPwnedService
|
||||
import com.bitwarden.network.service.IdentityService
|
||||
import com.bitwarden.network.service.OrganizationService
|
||||
import com.bitwarden.network.util.isSslHandShakeError
|
||||
import com.bitwarden.ui.platform.resource.BitwardenString
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||
@ -172,6 +174,7 @@ class AuthRepositoryImpl(
|
||||
private val policyManager: PolicyManager,
|
||||
private val userStateManager: UserStateManager,
|
||||
private val kdfManager: KdfManager,
|
||||
private val toastManager: ToastManager,
|
||||
logsManager: LogsManager,
|
||||
pushManager: PushManager,
|
||||
dispatcherManager: DispatcherManager,
|
||||
@ -1043,9 +1046,10 @@ class AuthRepositoryImpl(
|
||||
onSuccess = { it },
|
||||
)
|
||||
}
|
||||
val userId = activeAccount.profile.userId
|
||||
return vaultSdkSource
|
||||
.updatePassword(
|
||||
userId = activeAccount.profile.userId,
|
||||
userId = userId,
|
||||
newPassword = newPassword,
|
||||
)
|
||||
.flatMap { updatePasswordResponse ->
|
||||
@ -1071,14 +1075,15 @@ class AuthRepositoryImpl(
|
||||
)
|
||||
.onSuccess { passwordHash ->
|
||||
authDiskSource.storeMasterPasswordHash(
|
||||
userId = activeAccount.profile.userId,
|
||||
userId = userId,
|
||||
passwordHash = passwordHash,
|
||||
)
|
||||
}
|
||||
|
||||
toastManager.show(BitwardenString.updated_master_password)
|
||||
// Log out the user after successful password reset.
|
||||
// This clears all user state including forcePasswordResetReason.
|
||||
logout(reason = LogoutReason.PasswordReset)
|
||||
logout(reason = LogoutReason.PasswordReset, userId = userId)
|
||||
|
||||
// Return the success.
|
||||
ResetPasswordResult.Success
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.x8bit.bitwarden.data.auth.repository.di
|
||||
|
||||
import com.bitwarden.core.data.manager.dispatcher.DispatcherManager
|
||||
import com.bitwarden.core.data.manager.toast.ToastManager
|
||||
import com.bitwarden.data.datasource.disk.ConfigDiskSource
|
||||
import com.bitwarden.network.service.AccountsService
|
||||
import com.bitwarden.network.service.DevicesService
|
||||
@ -71,6 +72,7 @@ object AuthRepositoryModule {
|
||||
logsManager: LogsManager,
|
||||
userStateManager: UserStateManager,
|
||||
kdfManager: KdfManager,
|
||||
toastManager: ToastManager,
|
||||
): AuthRepository = AuthRepositoryImpl(
|
||||
clock = clock,
|
||||
accountsService = accountsService,
|
||||
@ -97,6 +99,7 @@ object AuthRepositoryModule {
|
||||
logsManager = logsManager,
|
||||
userStateManager = userStateManager,
|
||||
kdfManager = kdfManager,
|
||||
toastManager = toastManager,
|
||||
)
|
||||
|
||||
@Provides
|
||||
|
||||
@ -13,6 +13,7 @@ import com.bitwarden.core.UpdateKdfResponse
|
||||
import com.bitwarden.core.UpdatePasswordResponse
|
||||
import com.bitwarden.core.data.manager.dispatcher.DispatcherManager
|
||||
import com.bitwarden.core.data.manager.dispatcher.FakeDispatcherManager
|
||||
import com.bitwarden.core.data.manager.toast.ToastManager
|
||||
import com.bitwarden.core.data.repository.error.MissingPropertyException
|
||||
import com.bitwarden.core.data.repository.util.bufferedMutableSharedFlow
|
||||
import com.bitwarden.core.data.util.asFailure
|
||||
@ -68,6 +69,7 @@ import com.bitwarden.network.service.DevicesService
|
||||
import com.bitwarden.network.service.HaveIBeenPwnedService
|
||||
import com.bitwarden.network.service.IdentityService
|
||||
import com.bitwarden.network.service.OrganizationService
|
||||
import com.bitwarden.ui.platform.resource.BitwardenString
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
|
||||
@ -284,6 +286,9 @@ class AuthRepositoryTest {
|
||||
updateKdfToMinimumsIfNeeded(password = any())
|
||||
} returns UpdateKdfMinimumsResult.Success
|
||||
}
|
||||
private val toastManager: ToastManager = mockk {
|
||||
every { show(messageId = any(), duration = any()) } just runs
|
||||
}
|
||||
|
||||
private val repository: AuthRepository = AuthRepositoryImpl(
|
||||
clock = FIXED_CLOCK,
|
||||
@ -311,6 +316,7 @@ class AuthRepositoryTest {
|
||||
logsManager = logsManager,
|
||||
userStateManager = userStateManager,
|
||||
kdfManager = kdfManager,
|
||||
toastManager = toastManager,
|
||||
)
|
||||
|
||||
@BeforeEach
|
||||
@ -5501,7 +5507,8 @@ class AuthRepositoryTest {
|
||||
userId = USER_ID_1,
|
||||
passwordHash = newPasswordHash,
|
||||
)
|
||||
verify {
|
||||
verify(exactly = 1) {
|
||||
toastManager.show(messageId = BitwardenString.updated_master_password)
|
||||
userLogoutManager.logout(
|
||||
userId = ACCOUNT_1.profile.userId,
|
||||
reason = LogoutReason.PasswordReset,
|
||||
|
||||
@ -1198,4 +1198,5 @@ Do you want to switch to this account?</string>
|
||||
<string name="to_regain_access_to_your_archive_restart_your_premium_subscription">To regain access to your archive, restart your Premium subscription. If you edit details for an archived item before restarting, it’ll be moved back into your vault.</string>
|
||||
<string name="restart_premium">Restart Premium</string>
|
||||
<string name="items_transferred">Items transferred</string>
|
||||
<string name="updated_master_password">Updated master password</string>
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user