Allow FxA profile to refresh even when there exists a profile
This commit is contained in:
Родитель
dc813e2f50
Коммит
b2b66cb7c6
|
@ -524,6 +524,15 @@ open class FxAccountManager {
|
|||
)
|
||||
}
|
||||
}
|
||||
case let .fetchProfile(refresh): do {
|
||||
FxALog.info("Refreshing profile...")
|
||||
do {
|
||||
profile = try requireAccount().getProfile(forceRefresh: refresh)
|
||||
} catch {
|
||||
return Event.failedToFetchProfile
|
||||
}
|
||||
return Event.fetchedProfile
|
||||
}
|
||||
default: break // Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ extension FxAccountManager {
|
|||
}
|
||||
case .authenticatedWithProfile:
|
||||
switch event {
|
||||
case .fetchProfile: return .authenticatedWithProfile
|
||||
case .fetchedProfile: return .authenticatedWithProfile
|
||||
case .authenticationError: return .authenticationProblem
|
||||
case .changedPassword: return .authenticatedNoProfile
|
||||
case .logout: return .notAuthenticated
|
||||
|
|
|
@ -74,8 +74,8 @@ class FxAccountManagerTests: XCTestCase {
|
|||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .accountRestored))
|
||||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .authenticated(authData: FxaAuthData(code: "foo", state: "bar", actionQueryParam: "bobo"))))
|
||||
XCTAssertEqual(.authenticationProblem, FxAccountManager.nextState(state: state, event: .authenticationError))
|
||||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .fetchProfile(forceRefresh: false)))
|
||||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .fetchedProfile))
|
||||
XCTAssertEqual(.authenticatedWithProfile, FxAccountManager.nextState(state: state, event: .fetchProfile(forceRefresh: false)))
|
||||
XCTAssertEqual(.authenticatedWithProfile, FxAccountManager.nextState(state: state, event: .fetchedProfile))
|
||||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .failedToFetchProfile))
|
||||
XCTAssertEqual(.notAuthenticated, FxAccountManager.nextState(state: state, event: .logout))
|
||||
XCTAssertNil(FxAccountManager.nextState(state: state, event: .recoveredFromAuthenticationProblem))
|
||||
|
|
Загрузка…
Ссылка в новой задаче