Skip to content

Commit

Permalink
[Link] Remember OTP prompt cancelation (#823)
Browse files Browse the repository at this point in the history
* Remember OTP prompt decline

* Cleanup
  • Loading branch information
ramont-stripe authored Mar 4, 2022
1 parent 2222fcf commit 4b0c20b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Stripe/Link2FAViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ final class Link2FAViewController: UIViewController {
extension Link2FAViewController: Link2FAViewDelegate {

func link2FAViewDidCancel(_ view: Link2FAView) {
// Mark email as logged out to prevent automatically showing
// the 2FA modal in future checkout sessions.
linkAccount.markEmailAsLoggedOut()

completionBlock(.canceled)
}

Expand Down
13 changes: 9 additions & 4 deletions Stripe/PaymentSheetLinkAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,18 @@ class PaymentSheetLinkAccount: PaymentSheetLinkAccountInfoProtocol {
// Delete cookie.
cookieStore.delete(key: cookieStore.sessionCookieKey)

// Mark email as logged out
if let hashedEmail = email.lowercased().sha256 {
cookieStore.write(key: cookieStore.emailCookieKey, value: hashedEmail)
}
markEmailAsLoggedOut()

// Forget current session.
self.currentSession = nil
}

func markEmailAsLoggedOut() {
guard let hashedEmail = email.lowercased().sha256 else {
return
}

cookieStore.write(key: cookieStore.emailCookieKey, value: hashedEmail)
}

}

0 comments on commit 4b0c20b

Please sign in to comment.