@@ -19,8 +19,6 @@ import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
19
19
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
20
20
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
21
21
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
22
- import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeDisplayStatus
23
- import com.x8bit.bitwarden.data.auth.datasource.disk.model.NewDeviceNoticeState
24
22
import com.x8bit.bitwarden.data.auth.datasource.disk.model.OnboardingStatus
25
23
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
26
24
import com.x8bit.bitwarden.data.auth.datasource.network.model.DeleteAccountResponseJson
@@ -117,7 +115,6 @@ import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
117
115
import com.x8bit.bitwarden.data.platform.manager.util.getActivePolicies
118
116
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
119
117
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
120
- import com.x8bit.bitwarden.data.platform.repository.model.Environment
121
118
import com.x8bit.bitwarden.data.platform.repository.util.toEnvironmentUrls
122
119
import com.x8bit.bitwarden.data.vault.datasource.network.model.OrganizationType
123
120
import com.x8bit.bitwarden.data.vault.datasource.network.model.PolicyTypeJson
@@ -149,7 +146,6 @@ import kotlinx.coroutines.flow.onEach
149
146
import kotlinx.coroutines.flow.receiveAsFlow
150
147
import kotlinx.coroutines.flow.stateIn
151
148
import kotlinx.coroutines.flow.update
152
- import java.time.ZonedDateTime
153
149
import javax.inject.Singleton
154
150
155
151
/* *
@@ -1408,86 +1404,6 @@ class AuthRepositoryImpl(
1408
1404
}
1409
1405
}
1410
1406
1411
- override fun getNewDeviceNoticeState (): NewDeviceNoticeState ? {
1412
- return activeUserId?.let { userId ->
1413
- authDiskSource.getNewDeviceNoticeState(userId = userId)
1414
- }
1415
- }
1416
-
1417
- override fun setNewDeviceNoticeState (newState : NewDeviceNoticeState ? ) {
1418
- activeUserId?.let { userId ->
1419
- authDiskSource.storeNewDeviceNoticeState(userId = userId, newState = newState)
1420
- }
1421
- }
1422
-
1423
- override fun checkUserNeedsNewDeviceTwoFactorNotice (): Boolean {
1424
- return activeUserId
1425
- ?.let { userId ->
1426
- if (! newDeviceNoticePreConditionsValid()) {
1427
- return false
1428
- }
1429
-
1430
- val newDeviceNoticeState = authDiskSource.getNewDeviceNoticeState(userId = userId)
1431
- return when (newDeviceNoticeState.displayStatus) {
1432
- // if the user has already attested email access but permanent flag is enabled,
1433
- // the notice needs to appear again
1434
- NewDeviceNoticeDisplayStatus .CAN_ACCESS_EMAIL -> true
1435
- // if the user has already seen but 7 days have already passed,
1436
- // the notice needs to appear again
1437
- NewDeviceNoticeDisplayStatus .HAS_SEEN -> {
1438
- newDeviceNoticeState.shouldDisplayNoticeIfSeen
1439
- }
1440
-
1441
- NewDeviceNoticeDisplayStatus .HAS_NOT_SEEN -> true
1442
- // the user never needs to see the notice again
1443
- NewDeviceNoticeDisplayStatus .CAN_ACCESS_EMAIL_PERMANENT -> false
1444
- }
1445
- }
1446
- ? : false
1447
- }
1448
-
1449
- /* *
1450
- * Checks if the preconditions are met for a user to see a new device notice:
1451
- * - Must be a Bitwarden cloud user.
1452
- * - The account must be at least one week old.
1453
- * - Cannot have an active policy requiring SSO to be enabled.
1454
- * - Cannot have two-factor authentication enabled.
1455
- */
1456
- private fun newDeviceNoticePreConditionsValid (): Boolean {
1457
- val checkEnvironment = ! featureFlagManager.getFeatureFlag(FlagKey .IgnoreEnvironmentCheck )
1458
- val isSelfHosted = environmentRepository.environment.type == Environment .Type .SELF_HOSTED
1459
- if (checkEnvironment && isSelfHosted) {
1460
- return false
1461
- }
1462
-
1463
- val userProfile = authDiskSource.userState?.activeAccount?.profile
1464
- val isProfileAtLeastWeekOld = userProfile
1465
- ?.let {
1466
- it.creationDate
1467
- ?.plusWeeks(1 )
1468
- ?.isBefore(
1469
- ZonedDateTime .now(),
1470
- )
1471
- }
1472
- ? : false
1473
- if (! isProfileAtLeastWeekOld) {
1474
- return false
1475
- }
1476
-
1477
- val hasTwoFactorEnabled = userProfile
1478
- ?.isTwoFactorEnabled
1479
- ? : false
1480
- if (hasTwoFactorEnabled) {
1481
- return false
1482
- }
1483
-
1484
- val hasSSOPolicy =
1485
- policyManager.getActivePolicies(type = PolicyTypeJson .REQUIRE_SSO )
1486
- .any { p -> p.isEnabled }
1487
-
1488
- return ! hasSSOPolicy
1489
- }
1490
-
1491
1407
@Suppress(" CyclomaticComplexMethod" )
1492
1408
private suspend fun validatePasswordAgainstPolicy (
1493
1409
password : String ,
0 commit comments