Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable universal links support for QR code login #23953

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [*] Update site menu style on iPhone [#23944]
* [*] Integrate zoom transitions in Themes, Reader [#23945, #23947]
* [*] Fix an issue with site icons cropped in share extensions [#23950]
* [*] 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 }
Copy link
Contributor Author

@kean kean Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't reply on camera.stop because it has a race condition:

    func stop() {
        sessionQueue.async { [weak self] in
            self?.session?.stopRunning()
        }

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