Skip to content

Commit b76938b

Browse files
committed
[PM-19644] Remove two factor notice.
1 parent a702d3a commit b76938b

File tree

57 files changed

+0
-2041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+0
-2041
lines changed

BitwardenShared/Core/Platform/Models/Enum/FeatureFlag.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ enum FeatureFlag: String, CaseIterable, Codable {
5656
/// A feature flag for the create account flow.
5757
case nativeCreateAccountFlow = "native-create-account-flow"
5858

59-
/// A feature flag for the notice indicating a user does not have two-factor authentication set up.
60-
/// If true, the user can dismiss the notice temporarily.
61-
case newDeviceVerificationTemporaryDismiss = "new-device-temporary-dismiss"
62-
63-
/// A feature flag for the notice indicating a user does not have two-factor authentication set up.
64-
/// If true, the user can not dismiss the notice, and must set up two-factor authentication.
65-
/// Overrides the temporary flag.
66-
case newDeviceVerificationPermanentDismiss = "new-device-permanent-dismiss"
67-
6859
/// A feature flag for the refactor on the SSO details endpoint.
6960
case refactorSsoDetailsEndpoint = "pm-12337-refactor-sso-details-endpoint"
7061

@@ -128,8 +119,6 @@ enum FeatureFlag: String, CaseIterable, Codable {
128119
.flightRecorder,
129120
.ignore2FANoticeEnvironmentCheck,
130121
.mobileErrorReporting,
131-
.newDeviceVerificationPermanentDismiss,
132-
.newDeviceVerificationTemporaryDismiss,
133122
.testLocalFeatureFlag,
134123
.testLocalInitialBoolFlag,
135124
.testLocalInitialIntFlag,

BitwardenShared/Core/Platform/Services/StateService.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,6 @@ protocol StateService: AnyObject {
328328
///
329329
func getTimeoutAction(userId: String?) async throws -> SessionTimeoutAction
330330

331-
/// Gets the display state of the no-two-factor notice for a user ID.
332-
///
333-
/// - Parameters:
334-
/// - userId: The user ID for the account; defaults to current active user if `nil`.
335-
/// - Returns: The display state.
336-
///
337-
func getTwoFactorNoticeDisplayState(userId: String?) async throws -> TwoFactorNoticeDisplayState
338-
339331
/// Get the two-factor token (non-nil if the user selected the "remember me" option).
340332
///
341333
/// - Parameter email: The user's email address.
@@ -691,14 +683,6 @@ protocol StateService: AnyObject {
691683
///
692684
func setTimeoutAction(action: SessionTimeoutAction, userId: String?) async throws
693685

694-
/// Sets the user's no-two-factor notice display state for a userID.
695-
///
696-
/// - Parameters:
697-
/// - state: The display state to set.
698-
/// - userId: The user ID associated with the state
699-
///
700-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String?) async throws
701-
702686
/// Sets the user's two-factor token.
703687
///
704688
/// - Parameters:
@@ -1004,14 +988,6 @@ extension StateService {
1004988
try await getTimeoutAction(userId: nil)
1005989
}
1006990

1007-
/// Gets the display state of the no-two-factor notice for the current user.
1008-
///
1009-
/// - Returns: The display state.
1010-
///
1011-
func getTwoFactorNoticeDisplayState() async throws -> TwoFactorNoticeDisplayState {
1012-
try await getTwoFactorNoticeDisplayState(userId: nil)
1013-
}
1014-
1015991
/// Sets the number of unsuccessful attempts to unlock the vault for the active account.
1016992
///
1017993
/// - Returns: The number of unsuccessful unlock attempts for the active account.
@@ -1240,15 +1216,6 @@ extension StateService {
12401216
try await setSyncToAuthenticator(syncToAuthenticator, userId: nil)
12411217
}
12421218

1243-
/// Sets the display state for the no-two-factor notice
1244-
///
1245-
/// - Parameters:
1246-
/// - state: The state to set.
1247-
///
1248-
func setTwoFactorNoticeDisplayState(state: TwoFactorNoticeDisplayState) async throws {
1249-
try await setTwoFactorNoticeDisplayState(state, userId: nil)
1250-
}
1251-
12521219
/// Sets the session timeout action.
12531220
///
12541221
/// - Parameter action: The action to take when the user's session times out.
@@ -1652,11 +1619,6 @@ actor DefaultStateService: StateService { // swiftlint:disable:this type_body_le
16521619
return timeoutAction
16531620
}
16541621

1655-
func getTwoFactorNoticeDisplayState(userId: String?) async throws -> TwoFactorNoticeDisplayState {
1656-
let userId = try userId ?? getActiveAccountUserId()
1657-
return appSettingsStore.twoFactorNoticeDisplayState(userId: userId)
1658-
}
1659-
16601622
func getTwoFactorToken(email: String) async -> String? {
16611623
appSettingsStore.twoFactorToken(email: email)
16621624
}
@@ -1961,11 +1923,6 @@ actor DefaultStateService: StateService { // swiftlint:disable:this type_body_le
19611923
appSettingsStore.setTimeoutAction(key: action, userId: userId)
19621924
}
19631925

1964-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String?) async throws {
1965-
let userId = try userId ?? getActiveAccountUserId()
1966-
appSettingsStore.setTwoFactorNoticeDisplayState(state, userId: userId)
1967-
}
1968-
19691926
func setTwoFactorToken(_ token: String?, email: String) async {
19701927
appSettingsStore.setTwoFactorToken(token, email: email)
19711928
}

BitwardenShared/Core/Platform/Services/StateServiceTests.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -930,24 +930,6 @@ class StateServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body
930930
XCTAssertEqual(action, .logout)
931931
}
932932

933-
/// `getTwoFactorNoticeDisplayState(userId:)` gets the display state of the two-factor notice for the user.
934-
func test_getTwoFactorNoticeDisplayState() async throws {
935-
appSettingsStore.setTwoFactorNoticeDisplayState(.canAccessEmail, userId: "person@example.com")
936-
937-
let value = try await subject.getTwoFactorNoticeDisplayState(userId: "person@example.com")
938-
XCTAssertEqual(value, .canAccessEmail)
939-
}
940-
941-
/// `getTwoFactorNoticeDisplayState()` gets the display state of the two-factor notice for the current user
942-
/// and throws an error if there is no current user.
943-
func test_getTwoFactorNoticeDisplayState_noId() async throws {
944-
appSettingsStore.setTwoFactorNoticeDisplayState(.canAccessEmail, userId: "1")
945-
946-
await assertAsyncThrows(error: StateServiceError.noActiveAccount) {
947-
_ = try await subject.getTwoFactorNoticeDisplayState()
948-
}
949-
}
950-
951933
/// `getTwoFactorToken(email:)` gets the two-factor code associated with the email.
952934
func test_getTwoFactorToken() async {
953935
appSettingsStore.setTwoFactorToken("yay_you_win!", email: "winner@email.com")
@@ -2052,12 +2034,6 @@ class StateServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body
20522034
}
20532035
}
20542036

2055-
/// `setTwoFactorNoticeDisplayState(_:userId:)` sets the display state of the two-factor notice for the user.
2056-
func test_setTwoFactorNoticeDisplayState() async throws {
2057-
try await subject.setTwoFactorNoticeDisplayState(.hasNotSeen, userId: "person1@example.com")
2058-
XCTAssertEqual(appSettingsStore.twoFactorNoticeDisplayState(userId: "person1@example.com"), .hasNotSeen)
2059-
}
2060-
20612037
/// `setTwoFactorToken(_:email:)` sets the two-factor code for the email.
20622038
func test_setTwoFactorToken() async {
20632039
await subject.setTwoFactorToken("yay_you_win!", email: "winner@email.com")

BitwardenShared/Core/Platform/Services/Stores/AppSettingsStore.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,6 @@ protocol AppSettingsStore: AnyObject {
475475
///
476476
func setTimeoutAction(key: SessionTimeoutAction, userId: String)
477477

478-
/// Sets the display state for the two-factor notice.
479-
///
480-
/// - Parameters:
481-
/// - state: The display state.
482-
/// - userId: The userID associated with the state.
483-
///
484-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String)
485-
486478
/// Sets the two-factor token.
487479
///
488480
/// - Parameters:
@@ -544,14 +536,6 @@ protocol AppSettingsStore: AnyObject {
544536
///
545537
func timeoutAction(userId: String) -> Int?
546538

547-
/// Get the display state of the no-two-factor notice for a user ID.
548-
///
549-
/// - Parameters:
550-
/// - userId: The user ID associated with the state.
551-
/// - Returns: The state for the user ID.
552-
///
553-
func twoFactorNoticeDisplayState(userId: String) -> TwoFactorNoticeDisplayState
554-
555539
/// Get the two-factor token associated with a user's email.
556540
///
557541
/// - Parameter email: The user's email.
@@ -755,7 +739,6 @@ extension DefaultAppSettingsStore: AppSettingsStore {
755739
case shouldTrustDevice(userId: String)
756740
case syncToAuthenticator(userId: String)
757741
case state
758-
case twoFactorNoticeDisplayState(userId: String)
759742
case twoFactorToken(email: String)
760743
case unsuccessfulUnlockAttempts(userId: String)
761744
case usernameGenerationOptions(userId: String)
@@ -855,8 +838,6 @@ extension DefaultAppSettingsStore: AppSettingsStore {
855838
key = "state"
856839
case let .syncToAuthenticator(userId):
857840
key = "shouldSyncToAuthenticator_\(userId)"
858-
case let .twoFactorNoticeDisplayState(userId):
859-
key = "twoFactorNoticeDisplayState_\(userId)"
860841
case let .twoFactorToken(email):
861842
key = "twoFactorToken_\(email)"
862843
case let .unsuccessfulUnlockAttempts(userId):
@@ -1184,10 +1165,6 @@ extension DefaultAppSettingsStore: AppSettingsStore {
11841165
store(key, for: .vaultTimeoutAction(userId: userId))
11851166
}
11861167

1187-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String) {
1188-
store(state, for: .twoFactorNoticeDisplayState(userId: userId))
1189-
}
1190-
11911168
func setTwoFactorToken(_ token: String?, email: String) {
11921169
store(token, for: .twoFactorToken(email: email))
11931170
}
@@ -1212,10 +1189,6 @@ extension DefaultAppSettingsStore: AppSettingsStore {
12121189
fetch(for: .vaultTimeoutAction(userId: userId))
12131190
}
12141191

1215-
func twoFactorNoticeDisplayState(userId: String) -> TwoFactorNoticeDisplayState {
1216-
fetch(for: .twoFactorNoticeDisplayState(userId: userId)) ?? .hasNotSeen
1217-
}
1218-
12191192
func twoFactorToken(email: String) -> String? {
12201193
fetch(for: .twoFactorToken(email: email))
12211194
}

BitwardenShared/Core/Platform/Services/Stores/AppSettingsStoreTests.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -930,21 +930,6 @@ class AppSettingsStoreTests: BitwardenTestCase { // swiftlint:disable:this type_
930930
XCTAssertFalse(userDefaults.bool(forKey: "bwPreferencesStorage:shouldSyncToAuthenticator_2"))
931931
}
932932

933-
/// `twoFactorNoticeDisplayState(userId:)` returns `.hasNotSeen` if there isn't a previously stored value.
934-
func test_twoFactorNoticeDisplayState_isInitiallyNotSeen() {
935-
XCTAssertEqual(subject.twoFactorNoticeDisplayState(userId: "anyone@example.com"), .hasNotSeen)
936-
}
937-
938-
/// `twoFactorToken(email:)` can be used to get and set the persisted value in user defaults.
939-
func test_twoFactorNoticeDisplayState_withValue() {
940-
let date = Date()
941-
subject.setTwoFactorNoticeDisplayState(.canAccessEmail, userId: "person1@example.com")
942-
subject.setTwoFactorNoticeDisplayState(.seen(date), userId: "person2@example.com")
943-
944-
XCTAssertEqual(subject.twoFactorNoticeDisplayState(userId: "person1@example.com"), .canAccessEmail)
945-
XCTAssertEqual(subject.twoFactorNoticeDisplayState(userId: "person2@example.com"), .seen(date))
946-
}
947-
948933
/// `twoFactorToken(email:)` returns `nil` if there isn't a previously stored value.
949934
func test_twoFactorToken_isInitiallyNil() {
950935
XCTAssertNil(subject.twoFactorToken(email: "anything@email.com"))

BitwardenShared/Core/Platform/Services/Stores/TestHelpers/MockAppSettingsStore.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class MockAppSettingsStore: AppSettingsStore { // swiftlint:disable:this type_bo
5252
var shouldTrustDevice = [String: Bool?]()
5353
var syncToAuthenticatorByUserId = [String: Bool]()
5454
var timeoutAction = [String: Int]()
55-
var twoFactorNoticeDisplayState = [String: TwoFactorNoticeDisplayState]()
5655
var twoFactorTokens = [String: String]()
5756
var usesKeyConnector = [String: Bool]()
5857
var vaultTimeout = [String: Int]()
@@ -296,14 +295,6 @@ class MockAppSettingsStore: AppSettingsStore { // swiftlint:disable:this type_bo
296295
timeoutAction[userId] = key.rawValue
297296
}
298297

299-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String) {
300-
twoFactorNoticeDisplayState[userId] = state
301-
}
302-
303-
func twoFactorNoticeDisplayState(userId: String) -> TwoFactorNoticeDisplayState {
304-
twoFactorNoticeDisplayState[userId] ?? .hasNotSeen
305-
}
306-
307298
func setTwoFactorToken(_ token: String?, email: String) {
308299
twoFactorTokens[email] = token
309300
}

BitwardenShared/Core/Platform/Services/TestHelpers/MockStateService.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,11 @@ class MockStateService: StateService { // swiftlint:disable:this type_body_lengt
8080
var setAppRehydrationStateError: Error?
8181
var setBiometricAuthenticationEnabledResult: Result<Void, Error> = .success(())
8282
var setBiometricIntegrityStateError: Error?
83-
var setTwoFactorNoticeDisplayStateError: Error?
8483
var settingsBadgeSubject = CurrentValueSubject<SettingsBadgeState, Never>(.fixture())
8584
var shouldTrustDevice = [String: Bool?]()
8685
var syncToAuthenticatorByUserId = [String: Bool]()
8786
var syncToAuthenticatorResult: Result<Void, Error> = .success(())
8887
var syncToAuthenticatorSubject = CurrentValueSubject<(String?, Bool), Never>((nil, false))
89-
var twoFactorNoticeDisplayState = [String: TwoFactorNoticeDisplayState]()
90-
var twoFactorNoticeDisplayStateError: Error?
9188
var twoFactorTokens = [String: String]()
9289
var unsuccessfulUnlockAttempts = [String: Int]()
9390
var updateProfileResponse: ProfileResponseModel?
@@ -349,14 +346,6 @@ class MockStateService: StateService { // swiftlint:disable:this type_body_lengt
349346
return timeoutAction[userId] ?? .lock
350347
}
351348

352-
func getTwoFactorNoticeDisplayState(userId: String?) async throws -> TwoFactorNoticeDisplayState {
353-
if let error = twoFactorNoticeDisplayStateError {
354-
throw error
355-
}
356-
let userId = try unwrapUserId(userId)
357-
return twoFactorNoticeDisplayState[userId] ?? .hasNotSeen
358-
}
359-
360349
func getTwoFactorToken(email: String) async -> String? {
361350
twoFactorTokens[email]
362351
}
@@ -650,14 +639,6 @@ class MockStateService: StateService { // swiftlint:disable:this type_body_lengt
650639
accountTokens = Account.AccountTokens(accessToken: accessToken, refreshToken: refreshToken)
651640
}
652641

653-
func setTwoFactorNoticeDisplayState(_ state: TwoFactorNoticeDisplayState, userId: String?) async throws {
654-
if let error = setTwoFactorNoticeDisplayStateError {
655-
throw error
656-
}
657-
let userId = try unwrapUserId(userId)
658-
twoFactorNoticeDisplayState[userId] = state
659-
}
660-
661642
func setTwoFactorToken(_ token: String?, email: String) async {
662643
twoFactorTokens[email] = token
663644
}

BitwardenShared/Core/Platform/Utilities/Constants.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@ extension Constants {
8484

8585
/// The default number of KDF iterations to perform.
8686
static let pbkdf2Iterations = 600_000
87-
88-
/// The minimum number of seconds an account must have existed for before
89-
/// we display the two-factor notice.
90-
static let twoFactorNoticeMinimumAccountAgeInterval: TimeInterval = 86400 * 7 // Seven days
91-
92-
/// The minimum number of seconds after a user delays the two-factor notice
93-
/// before we display the notice again.
94-
static let twoFactorNoticeDelayInterval: TimeInterval = 86400 * 7 // Seven days
9587
}
9688

9789
// MARK: Extension Constants

BitwardenShared/UI/Auth/TwoFactorNotice/Alert+TwoFactorNotice.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)