Skip to content

Commit

Permalink
Disable universal links support for QR code login (#23953)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean authored Jan 7, 2025
2 parents 530faff + 011b671 commit 4b41387
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* [*] Integrate zoom transitions in Themes, Reader [#23945, #23947]
* [*] Fix an issue with site icons cropped in share extensions [#23950]
* [*] Enable fast deceleration for filters on the Discover tab [#23954]

* [*] Disable universal links support for QR code login. You can only scan the codes using the app now. [#23953]

25.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ struct QRLoginCoordinator: QRLoginParentCoordinator {

static func didHandle(url: URL) -> Bool {
guard
let token = QRLoginURLParser(urlString: url.absoluteString).parse(),
let _ = QRLoginURLParser(urlString: url.absoluteString).parse(),
let source = UIApplication.shared.leafViewController
else {
return false
}

self.init(origin: .deepLink).showVerifyAuthorization(token: token, from: source)
self.init(origin: .deepLink).showCameraScanningView(from: source)
Notice(title: Strings.scanFromApp).post()
return true
}

Expand All @@ -34,10 +34,7 @@ struct QRLoginCoordinator: QRLoginParentCoordinator {

func showVerifyAuthorization(token: QRLoginToken, from source: UIViewController? = nil) {
let controller = QRLoginVerifyAuthorizationViewController()
controller.coordinator = QRLoginVerifyCoordinator(token: token,
view: controller,
parentCoordinator: self)

controller.coordinator = QRLoginVerifyCoordinator(token: token, view: controller, parentCoordinator: self)
pushOrPresent(controller, from: source)
}
}
Expand Down Expand Up @@ -115,3 +112,7 @@ extension QRLoginCoordinator {
QRLoginCoordinator(origin: origin).showVerifyAuthorization(token: token, from: source)
}
}

private enum Strings {
static let scanFromApp = NSLocalizedString("qrLogin.codeHasToBeScannedFromTheAppNotice.title", value: "Please scan the code using the app", comment: "Informational notice title. Showed when you scan a code using a camera app outside of the app, which is not allowed.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class QRLoginScanningCoordinator: NSObject {
let parentCoordinator: QRLoginParentCoordinator
let view: QRLoginScanningView
var cameraSession: QRCodeScanningSession
private var didHandleToken = false

init(view: QRLoginScanningView, parentCoordinator: QRLoginParentCoordinator, cameraSession: QRCodeScanningSession = QRLoginCameraSession()) {
self.view = view
Expand Down Expand Up @@ -48,6 +49,9 @@ extension QRLoginScanningCoordinator {
}

func didScanToken(_ token: QRLoginToken) {
guard !didHandleToken else { return }
didHandleToken = true // Prevents the subsequent captures.

parentCoordinator.track(.qrLoginScannerScannedCode)

// Give the user a tap to let them know they've successfully scanned the code
Expand Down

0 comments on commit 4b41387

Please sign in to comment.