Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

1556 Refresh user access token on creating new account and coming bac… #336

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion Source/UI/IdentityUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,14 @@ extension IdentityUI {
self?.complete(with: output, presentingViewController: presentingViewController)
}
}
case let .validateAuthCode(code, shouldPersistUser, codeVerifier):
case let .validateAuthCode(code, shouldPersistUser, codeVerifier, codeAfterSignup):
// Let's check if the code validates.
authenticationCodeInteractor.validate(authCode: code, codeVerifier: codeVerifier) { [weak self] result in
switch result {
case let .success(user):
if codeAfterSignup {
self?._identityManager.currentUser.refresh(completion: { _ in })
}
self?.configuration.tracker?.loginID = self?._identityManager.currentUser.legacyID
// User has validated the identifier and the code matches, nothing else to do.
self?.complete(with: .success(user: user, persistUser: shouldPersistUser), presentingViewController: presentingViewController)
Expand Down
4 changes: 2 additions & 2 deletions Source/UI/IdentityUIRoute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension IdentityUI {
case enterPassword(for: EmailAddress, scopes: [String])

/// Route to validate an authcode
case validateAuthCode(code: String, shouldPersistUser: Bool?, codeVerifier: String? = nil)
case validateAuthCode(code: String, shouldPersistUser: Bool?, codeVerifier: String? = nil, codeAfterSignup: Bool = false)

var loginMethod: LoginMethod {
switch self {
Expand Down Expand Up @@ -68,7 +68,7 @@ public extension IdentityUI.Route {
}
self = .enterPassword(for: email, scopes: scopes)
case let .codeAfterSignup(code, shouldPersistUser):
self = .validateAuthCode(code: code, shouldPersistUser: shouldPersistUser)
self = .validateAuthCode(code: code, shouldPersistUser: shouldPersistUser, codeAfterSignup: true)
case let .codeAfterUnvalidatedLogin(code):
// We have no way to retrieve the `shouldPersistUser` flag from the redirect URL in this case, so we just fall back to `false`.
self = .validateAuthCode(code: code, shouldPersistUser: false)
Expand Down