Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-8217] New device two factor notice #4508

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5741333
[PM-8217] New device notice email address access screen, viewmodel anโ€ฆ
andrebispo5 Dec 2, 2024
cb26200
[PM-8217] New device notice email address access tests
andrebispo5 Dec 2, 2024
35c8b1c
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 2, 2024
0c74547
[PM-8217] Fix navigation parameter and ui alignment.
andrebispo5 Dec 2, 2024
9b20ad6
[PM-8217] Add option to include an icon on the right side of the Bitwโ€ฆ
andrebispo5 Dec 2, 2024
e784b85
[PM-8217] Add new device notice two factor screen, viewmodel and naviโ€ฆ
andrebispo5 Dec 2, 2024
02803c3
[PM-8217] Remove scroll behaviour. Remove suppression for long methodโ€ฆ
andrebispo5 Dec 2, 2024
58ab96f
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 2, 2024
ee645b5
[PM-8217] Fixed screen layout
andrebispo5 Dec 2, 2024
c711348
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 2, 2024
f364d81
Merge branch 'pm-8217/new-device-notice-ui' into pm-8217/new-device-nโ€ฆ
andrebispo5 Dec 3, 2024
83402a3
[PM-8217] Fix layout
andrebispo5 Dec 3, 2024
af0f299
[PM-8217] Add todo for remind me later logic
andrebispo5 Dec 3, 2024
804e3f4
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 3, 2024
a84fb9a
Merge branch 'pm-8217/new-device-notice-ui' into pm-8217/new-device-nโ€ฆ
andrebispo5 Dec 3, 2024
d595125
[PM-8217] Add tests to new device notice two factor screen and viewmoโ€ฆ
andrebispo5 Dec 4, 2024
40edba4
[PM-8217] lint
andrebispo5 Dec 4, 2024
00b0680
[PM-8217] Fix layout
andrebispo5 Dec 4, 2024
0eb63a2
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 17, 2024
b8fae5a
[PM-8217] Update layout with new design
andrebispo5 Dec 17, 2024
cb28215
Merge branch 'pm-8217/new-device-notice-ui' of https://github.com/bitโ€ฆ
andrebispo5 Dec 17, 2024
9933745
Merge branch 'pm-8217/new-device-notice-ui' into pm-8217/new-device-nโ€ฆ
andrebispo5 Dec 17, 2024
0ca30ef
[PM-8217] Revert Bitwarden button changes
andrebispo5 Dec 17, 2024
6eefde1
[PM-8217] Update screen with new design changes
andrebispo5 Dec 17, 2024
519554c
[PM-8217] Fix and improve screen tests
andrebispo5 Dec 17, 2024
4290a7f
[PM-8217] Fix screen tests
andrebispo5 Dec 18, 2024
b459632
Merge branch 'main' into pm-8217/new-device-notice-ui
andrebispo5 Dec 18, 2024
dd9bf3f
Merge branch 'pm-8217/new-device-notice-ui' into pm-8217/new-device-nโ€ฆ
andrebispo5 Dec 18, 2024
7cee495
[PM-8217] Fix drawable
andrebispo5 Dec 18, 2024
c3d08ff
[PM-8217] Fix drawable
andrebispo5 Dec 18, 2024
157a0ca
[PM-8217] Added TODO for future PR reference
andrebispo5 Dec 19, 2024
0bb3a1c
[PM-8217] Fix PR comments
andrebispo5 Dec 20, 2024
d79ca14
Merge branch 'pm-8217/new-device-notice-ui' into pm-8217/new-device-nโ€ฆ
andrebispo5 Dec 20, 2024
f4d8e4d
[PM-8217] Added column scope
andrebispo5 Dec 20, 2024
5bcb00a
Merge branch 'pm-8217/new-device-notice-ui-twofa' into pm-8217/new-deโ€ฆ
andrebispo5 Dec 20, 2024
bdbfcf9
Merge branch 'main' into pm-8217/new-device-notice-ui-twofa
andrebispo5 Dec 20, 2024
a214da4
Merge branch 'pm-8217/new-device-notice-ui-twofa' into pm-8217/new-deโ€ฆ
andrebispo5 Dec 20, 2024
7886e92
[PM-8217] Add isTwoFactorEnabled and creationDate to user account
andrebispo5 Dec 20, 2024
ed4e77c
[PM-8217] Add feature flags definition
andrebispo5 Dec 20, 2024
835d182
[PM-8217] Add isTwoFactorEnabled and creationDate to user account
andrebispo5 Dec 20, 2024
1af8b63
[PM-8217] Add creationDate and isTwoFactorEnable properties to tests
andrebispo5 Dec 23, 2024
1d78eb2
Merge branch 'main' into pm-8217/new-device-notice-navigation
andrebispo5 Dec 23, 2024
32a659e
Merge branch 'pm-8217/creation-2fa-properties' into pm-8217/new-devicโ€ฆ
andrebispo5 Dec 23, 2024
b2e9a2f
[PM-8217] Add to AuthDiskSource NewDeviceNoticeState.
andrebispo5 Dec 23, 2024
161fa69
[PM-8217] Model class for Notice State
andrebispo5 Dec 23, 2024
29c9d48
[PM-8217] Feature flags resource string for debug menu
andrebispo5 Dec 23, 2024
4205c56
[PM-8217] Add non localized resource for debug menu
andrebispo5 Dec 23, 2024
aa8f796
[PM-8217] Fix NewDeviceNoticeDisplayStatus at least 7 days old computโ€ฆ
andrebispo5 Dec 23, 2024
d83a032
[PM-8217] Add logic to check if user needs to be shown the new deviceโ€ฆ
andrebispo5 Dec 23, 2024
2a9f7fb
[PM-8217] Update email access screen and logic
andrebispo5 Dec 23, 2024
d18dcb9
[PM-8217] Update two factor screen and logic
andrebispo5 Dec 23, 2024
2a1abcf
[PM-8217] Update email access tests
andrebispo5 Dec 23, 2024
a942e64
[PM-8217] Add navigations into RootNav for the new device notice
andrebispo5 Dec 23, 2024
7cc27d7
Merge branch 'main' into pm-8217/new-device-notice-navigation
andrebispo5 Dec 23, 2024
3d7bafb
[PM-8217] Hide remind me later button based on feature flag
andrebispo5 Dec 24, 2024
b4d757f
[PM-8217] Add feature flag tests
andrebispo5 Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.x8bit.bitwarden.data.auth.datasource.disk

import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
import com.x8bit.bitwarden.data.auth.datasource.disk.model.PendingAuthRequestJson
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
Expand Down Expand Up @@ -328,7 +329,17 @@ interface AuthDiskSource {
fun storeShowImportLogins(userId: String, showImportLogins: Boolean?)

/**
* Emits updates that track [getShowImportLogins]. This will replay the last known value,
* Emits updates that track [getShowImportLogins]. This will replay the last known value.
*/
fun getShowImportLoginsFlow(userId: String): Flow<Boolean?>

/**
* Gets the new device notice state for the given [userId].
*/
fun getNewDeviceNoticeState(userId: String): NewDeviceNoticeState

/**
* Stores the new device notice state for the given [userId].
*/
fun storeNewDeviceNoticeState(userId: String, newState: NewDeviceNoticeState?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.SharedPreferences
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
import com.x8bit.bitwarden.data.auth.datasource.disk.model.PendingAuthRequestJson
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
Expand Down Expand Up @@ -46,6 +48,7 @@
private const val USES_KEY_CONNECTOR = "usesKeyConnector"
private const val ONBOARDING_STATUS_KEY = "onboardingStatus"
private const val SHOW_IMPORT_LOGINS_KEY = "showImportLogins"
private const val NEW_DEVICE_NOTICE_STATE = "newDeviceNoticeState"

/**
* Primary implementation of [AuthDiskSource].
Expand Down Expand Up @@ -471,6 +474,22 @@
getMutableShowImportLoginsFlow(userId)
.onSubscription { emit(getShowImportLogins(userId)) }

override fun getNewDeviceNoticeState(userId: String): NewDeviceNoticeState {
return getString(key = NEW_DEVICE_NOTICE_STATE.appendIdentifier(userId))?.let {
json.decodeFromStringOrNull(it)
} ?: NewDeviceNoticeState(
displayStatus = NewDeviceNoticeDisplayStatus.HAS_NOT_SEEN,
delayDate = null,

Check warning on line 482 in app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt#L480-L482

Added lines #L480 - L482 were not covered by tests
)
}

override fun storeNewDeviceNoticeState(userId: String, newState: NewDeviceNoticeState?) {
putString(
key = NEW_DEVICE_NOTICE_STATE.appendIdentifier(userId),
value = newState?.let { json.encodeToString(it) },
)
}

private fun generateAndStoreUniqueAppId(): String =
UUID
.randomUUID()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.x8bit.bitwarden.data.auth.datasource.disk.model

import kotlinx.serialization.Contextual
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.time.ZonedDateTime

/**
* Describes the current display status of the new device notice screen.
*/
@Serializable
enum class NewDeviceNoticeDisplayStatus {
/**
* The user has seen the screen and indicated they can access their email.
*/
@SerialName("canAccessEmail")
CAN_ACCESS_EMAIL,

/**
* The user has indicated they can access their email
* as specified by the Permanent mode of the notice.
*/
@SerialName("canAccessEmailPermanent")
CAN_ACCESS_EMAIL_PERMANENT,

/**
* The user has not seen the screen.
*/
@SerialName("hasNotSeen")
HAS_NOT_SEEN,

/**
* The user has seen the screen and selected "remind me later".
*/
@SerialName("hasSeen")
HAS_SEEN,
}

/**
* The state of the new device notice screen.
*/
@Suppress("MagicNumber")
@Serializable
data class NewDeviceNoticeState(
@SerialName("displayStatus")
val displayStatus: NewDeviceNoticeDisplayStatus,

@SerialName("delayDate")
@Contextual
val delayDate: ZonedDateTime?,
) {
/**
* Whether the [delayDate] is at least 7 days old.
*/
val delayDateIsSevenDaysOld = delayDate?.isBefore(ZonedDateTime.now().minusDays(7)) ?: false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.x8bit.bitwarden.data.auth.repository

import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
import com.x8bit.bitwarden.data.auth.datasource.network.model.GetTokenResponseJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.TwoFactorDataModel
Expand Down Expand Up @@ -401,4 +402,19 @@ interface AuthRepository : AuthenticatorProvider, AuthRequestManager {
* Update the value of the onboarding status for the user.
*/
fun setOnboardingStatus(userId: String, status: OnboardingStatus?)

/**
* Checks if a new device notice should be displayed.
*/
fun checkUserNeedsNewDeviceTwoFactorNotice(): Boolean

/**
* Gets the new device notice state of active user.
*/
fun getNewDeviceNoticeState(): NewDeviceNoticeState?

/**
* Stores the new device notice state for active user.
*/
fun setNewDeviceNoticeState(newState: NewDeviceNoticeState?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
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
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.DeleteAccountResponseJson
Expand Down Expand Up @@ -106,6 +108,7 @@
import com.x8bit.bitwarden.data.platform.manager.util.getActivePolicies
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
import com.x8bit.bitwarden.data.platform.repository.model.Environment
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
import com.x8bit.bitwarden.data.platform.repository.util.toEnvironmentUrls
import com.x8bit.bitwarden.data.platform.util.asFailure
Expand Down Expand Up @@ -141,6 +144,7 @@
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import java.time.ZonedDateTime
import javax.inject.Singleton

/**
Expand Down Expand Up @@ -1333,6 +1337,80 @@
authDiskSource.storeOnboardingStatus(userId = userId, onboardingStatus = status)
}

override fun getNewDeviceNoticeState(): NewDeviceNoticeState? {
return activeUserId?.let { userId ->
authDiskSource.getNewDeviceNoticeState(userId = userId)
}
}

override fun setNewDeviceNoticeState(newState: NewDeviceNoticeState?) {
activeUserId?.let { userId ->
authDiskSource.storeNewDeviceNoticeState(userId = userId, newState = newState)
}
}

override fun checkUserNeedsNewDeviceTwoFactorNotice(): Boolean {
return activeUserId?.let { userId ->
val temporaryFlag = featureFlagManager.getFeatureFlag(FlagKey.NewDeviceTemporaryDismiss)
val permanentFlag = featureFlagManager.getFeatureFlag(FlagKey.NewDevicePermanentDismiss)

// check if feature flags are disabled
if (!temporaryFlag && !permanentFlag) {
return false
}

if (!newDeviceNoticePreConditionsValid()) {
return false
}

val newDeviceNoticeState = authDiskSource.getNewDeviceNoticeState(userId = userId)
return when (newDeviceNoticeState.displayStatus) {
// if the user has already attested email access but permanent flag is enabled,
// the notice needs to appear again
NewDeviceNoticeDisplayStatus.CAN_ACCESS_EMAIL -> permanentFlag
// if the user has already seen but 7 days have already passed,
// the notice needs to appear again
NewDeviceNoticeDisplayStatus.HAS_SEEN ->
newDeviceNoticeState.delayDateIsSevenDaysOld
NewDeviceNoticeDisplayStatus.HAS_NOT_SEEN -> true
// the user never needs to see the notice again
NewDeviceNoticeDisplayStatus.CAN_ACCESS_EMAIL_PERMANENT -> false
}
}
?: false

Check warning on line 1380 in app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt#L1380

Added line #L1380 was not covered by tests
}

private fun newDeviceNoticePreConditionsValid(): Boolean {
val hasSSOPolicy =
policyManager.getActivePolicies(type = PolicyTypeJson.REQUIRE_SSO)
.any { p -> p.isEnabled }
val isCloudUser = environmentRepository.environment.type != Environment.Type.SELF_HOSTED
val userProfile = authDiskSource.userState?.activeAccount?.profile
val hasTwoFactorEnabled = userProfile
?.isTwoFactorEnabled
?: false

Check warning on line 1391 in app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt#L1391

Added line #L1391 was not covered by tests
val isProfileAtLeastWeekOld = userProfile
?.let {
it.creationDate
?.plusWeeks(1)
?.isBefore(
ZonedDateTime.now(),
)
}
?: false

Check warning on line 1400 in app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt#L1400

Added line #L1400 was not covered by tests

// broken down for easier readability
if (!isCloudUser || !isProfileAtLeastWeekOld) {
return false
}

if (hasSSOPolicy || hasTwoFactorEnabled) {
return false
}

return true
}

@Suppress("CyclomaticComplexMethod")
private suspend fun validatePasswordAgainstPolicy(
password: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ sealed class FlagKey<out T : Any> {
override val isRemotelyConfigured: Boolean = true
}

/**
* Data object holding the feature flag key for the New Device Temporary Dismiss feature.
*/
data object NewDeviceTemporaryDismiss : FlagKey<Boolean>() {
override val keyName: String = "new-device-temporary-dismiss"
override val defaultValue: Boolean = false
override val isRemotelyConfigured: Boolean = true
}

/**
* Data object holding the feature flag key for the New Device Permanent Dismiss feature.
*/
data object NewDevicePermanentDismiss : FlagKey<Boolean>() {
override val keyName: String = "new-device-permanent-dismiss"
override val defaultValue: Boolean = false
override val isRemotelyConfigured: Boolean = true
}

//region Dummy keys for testing
/**
* Data object holding the key for a [Boolean] flag to be used in tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fun NavController.navigateToNewDeviceNoticeEmailAccess(
* Add the new device notice email access screen to the nav graph.
*/
fun NavGraphBuilder.newDeviceNoticeEmailAccessDestination(
onNavigateBackToVault: () -> Unit,
onNavigateToTwoFactorOptions: () -> Unit,
) {
composableWithSlideTransitions(
Expand All @@ -50,6 +51,7 @@ fun NavGraphBuilder.newDeviceNoticeEmailAccessDestination(
),
) {
NewDeviceNoticeEmailAccessScreen(
onNavigateBackToVault = onNavigateBackToVault,
onNavigateToTwoFactorOptions = onNavigateToTwoFactorOptions,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
*/
@Composable
fun NewDeviceNoticeEmailAccessScreen(
onNavigateBackToVault: () -> Unit,
onNavigateToTwoFactorOptions: () -> Unit,
viewModel: NewDeviceNoticeEmailAccessViewModel = hiltViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
EventsEffect(viewModel = viewModel) { event ->
when (event) {
NavigateToTwoFactorOptions -> onNavigateToTwoFactorOptions()
NewDeviceNoticeEmailAccessEvent.NavigateBackToVault -> onNavigateBackToVault()

Check warning on line 55 in app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/newdevicenotice/NewDeviceNoticeEmailAccessScreen.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/newdevicenotice/NewDeviceNoticeEmailAccessScreen.kt#L55

Added line #L55 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

import android.os.Parcelable
import androidx.lifecycle.SavedStateHandle
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus.CAN_ACCESS_EMAIL
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus.CAN_ACCESS_EMAIL_PERMANENT
import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
import com.x8bit.bitwarden.data.auth.repository.AuthRepository
import com.x8bit.bitwarden.data.platform.manager.FeatureFlagManager
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
import com.x8bit.bitwarden.ui.auth.feature.newdevicenotice.NewDeviceNoticeEmailAccessAction.ContinueClick
import com.x8bit.bitwarden.ui.auth.feature.newdevicenotice.NewDeviceNoticeEmailAccessAction.EmailAccessToggle
import com.x8bit.bitwarden.ui.auth.feature.newdevicenotice.NewDeviceNoticeEmailAccessEvent.NavigateToTwoFactorOptions
import com.x8bit.bitwarden.ui.platform.base.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.update
import kotlinx.parcelize.Parcelize
import java.time.ZonedDateTime
import javax.inject.Inject

private const val KEY_STATE = "state"
Expand All @@ -18,6 +25,8 @@
*/
@HiltViewModel
class NewDeviceNoticeEmailAccessViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val featureFlagManager: FeatureFlagManager,
savedStateHandle: SavedStateHandle,
) : BaseViewModel<
NewDeviceNoticeEmailAccessState,
Expand All @@ -38,8 +47,24 @@
}

private fun handleContinueClick() {
// TODO PM-8217: update new device notice status and navigate accordingly
sendEvent(NavigateToTwoFactorOptions)
if (state.isEmailAccessEnabled) {
val displayStatus =
if (featureFlagManager.getFeatureFlag(FlagKey.NewDevicePermanentDismiss)) {
CAN_ACCESS_EMAIL_PERMANENT
} else {
CAN_ACCESS_EMAIL

Check warning on line 55 in app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/newdevicenotice/NewDeviceNoticeEmailAccessViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/newdevicenotice/NewDeviceNoticeEmailAccessViewModel.kt#L55

Added line #L55 was not covered by tests
}

authRepository.setNewDeviceNoticeState(
NewDeviceNoticeState(
displayStatus = displayStatus,
delayDate = ZonedDateTime.now(),
),
)
sendEvent(NewDeviceNoticeEmailAccessEvent.NavigateBackToVault)
} else {
sendEvent(NavigateToTwoFactorOptions)
}
}

private fun handleEmailAccessToggle(action: EmailAccessToggle) {
Expand All @@ -66,6 +91,11 @@
* Navigates to the Two Factor Options screen.
*/
data object NavigateToTwoFactorOptions : NewDeviceNoticeEmailAccessEvent()

/**
* Navigates back.
*/
data object NavigateBackToVault : NewDeviceNoticeEmailAccessEvent()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ fun NavController.navigateToNewDeviceNoticeTwoFactor(
* Add the new device notice two factor screen to the nav graph.
*/
fun NavGraphBuilder.newDeviceNoticeTwoFactorDestination(
onNavigateBack: () -> Unit,
onNavigateBackToVault: () -> Unit,
) {
composableWithSlideTransitions(
route = NEW_DEVICE_NOTICE_TWO_FACTOR_ROUTE,
) {
NewDeviceNoticeTwoFactorScreen(
onNavigateBack = onNavigateBack,
onNavigateBackToVault = onNavigateBackToVault,
)
}
}
Loading