Skip to content

Commit

Permalink
PM-14597 remove notification if device login is decleined (#4256)
Browse files Browse the repository at this point in the history
  • Loading branch information
dseverns-livefront authored Nov 11, 2024
1 parent 771e719 commit fd4a7c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,8 @@ class LoginWithDeviceViewModel @Inject constructor(
}
}

CreateAuthRequestResult.Declined -> {
when (state.loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> {
mutableStateFlow.update {
it.copy(
viewState = LoginWithDeviceState.ViewState.Content(
loginWithDeviceType = it.loginWithDeviceType,
fingerprintPhrase = "",
isResendNotificationLoading = false,
),
dialogState = LoginWithDeviceState.DialogState.Error(
title = null,
message = R.string.this_request_is_no_longer_valid.asText(),
),
)
}
}

LoginWithDeviceType.SSO_ADMIN_APPROVAL -> {
// Do nothing, the user should not be informed of this state
}
}
}
// Do nothing, the user should not be informed of this state
CreateAuthRequestResult.Declined -> Unit

CreateAuthRequestResult.Expired -> {
mutableStateFlow.update {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,23 +524,17 @@ class LoginWithDeviceViewModelTest : BaseViewModelTest() {

@Suppress("MaxLineLength")
@Test
fun `on createAuthRequestWithUpdates with OTHER_DEVICE, Declined received should show error dialog`() {
val viewModel = createViewModel()
assertEquals(DEFAULT_STATE, viewModel.stateFlow.value)
mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined)
assertEquals(
DEFAULT_STATE.copy(
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
fingerprintPhrase = "",
isResendNotificationLoading = false,
),
dialogState = LoginWithDeviceState.DialogState.Error(
title = null,
message = R.string.this_request_is_no_longer_valid.asText(),
),
fun `on createAuthRequestWithUpdates with OTHER_DEVICE, Declined received should show unchanged content`() {
val initialState = DEFAULT_STATE.copy(
loginWithDeviceType = LoginWithDeviceType.OTHER_DEVICE,
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
loginWithDeviceType = LoginWithDeviceType.OTHER_DEVICE,
),
viewModel.stateFlow.value,
)
val viewModel = createViewModel(state = initialState)
assertEquals(initialState, viewModel.stateFlow.value)
mutableCreateAuthRequestWithUpdatesFlow.tryEmit(CreateAuthRequestResult.Declined)
assertEquals(initialState, viewModel.stateFlow.value)
}

@Suppress("MaxLineLength")
Expand Down

0 comments on commit fd4a7c5

Please sign in to comment.