Skip to content

Commit

Permalink
Fix sign in even when you need to go through 2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviuvsp committed Dec 13, 2024
1 parent 6939d35 commit 293de4d
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ class AuthVerifyIdentityViewModel: ObservableObject {
return
}
containerViewModel.isLoading = true
AuthenticationManager.shared.verify2FA(code: pinCode) { result in
AuthenticationManager.shared.verify2FA(code: pinCode) {[weak self] result in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.digitsDisabled = false
self?.digitsDisabled = false
}
self.containerViewModel.isLoading = false
self?.containerViewModel.isLoading = false
switch result {
case .success:
handler(.success)
self?.trackLoginEvent()
case .error(_):
self.pinCode = ""
self.containerViewModel.displayErrorBanner(bannerErrorMessage: .invalidPinCode)
self?.pinCode = ""
self?.containerViewModel.displayErrorBanner(bannerErrorMessage: .invalidPinCode)
handler(.invalidPinCode)
}
}
Expand All @@ -63,4 +64,13 @@ class AuthVerifyIdentityViewModel: ObservableObject {
}
}
}

func trackLoginEvent() {
guard let accountId = AuthenticationManager.shared.session?.account.accountID,
let payload = EventsPayloadBuilder.build(accountId: accountId,
eventAction: AccountEventAction.login,
entityId: String(accountId)) else { return }
let updateAccountOperation = APIOperation(EventsEndpoint.sendEvent(eventsPayload: payload))
updateAccountOperation.execute(in: APIRequestDispatcher()) {_ in}
}
}

0 comments on commit 293de4d

Please sign in to comment.