Skip to content

Commit 4b41387

Browse files
authored
Disable universal links support for QR code login (#23953)
2 parents 530faff + 011b671 commit 4b41387

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* [*] Integrate zoom transitions in Themes, Reader [#23945, #23947]
1818
* [*] Fix an issue with site icons cropped in share extensions [#23950]
1919
* [*] Enable fast deceleration for filters on the Discover tab [#23954]
20-
20+
* [*] Disable universal links support for QR code login. You can only scan the codes using the app now. [#23953]
2121

2222
25.6
2323
-----

WordPress/Classes/ViewRelated/QR Login/Coordinators/QRLoginCoordinator.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct QRLoginCoordinator: QRLoginParentCoordinator {
1818

1919
static func didHandle(url: URL) -> Bool {
2020
guard
21-
let token = QRLoginURLParser(urlString: url.absoluteString).parse(),
21+
let _ = QRLoginURLParser(urlString: url.absoluteString).parse(),
2222
let source = UIApplication.shared.leafViewController
2323
else {
2424
return false
2525
}
26-
27-
self.init(origin: .deepLink).showVerifyAuthorization(token: token, from: source)
26+
self.init(origin: .deepLink).showCameraScanningView(from: source)
27+
Notice(title: Strings.scanFromApp).post()
2828
return true
2929
}
3030

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

3535
func showVerifyAuthorization(token: QRLoginToken, from source: UIViewController? = nil) {
3636
let controller = QRLoginVerifyAuthorizationViewController()
37-
controller.coordinator = QRLoginVerifyCoordinator(token: token,
38-
view: controller,
39-
parentCoordinator: self)
40-
37+
controller.coordinator = QRLoginVerifyCoordinator(token: token, view: controller, parentCoordinator: self)
4138
pushOrPresent(controller, from: source)
4239
}
4340
}
@@ -115,3 +112,7 @@ extension QRLoginCoordinator {
115112
QRLoginCoordinator(origin: origin).showVerifyAuthorization(token: token, from: source)
116113
}
117114
}
115+
116+
private enum Strings {
117+
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.")
118+
}

WordPress/Classes/ViewRelated/QR Login/Coordinators/QRLoginScanningCoordinator.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class QRLoginScanningCoordinator: NSObject {
44
let parentCoordinator: QRLoginParentCoordinator
55
let view: QRLoginScanningView
66
var cameraSession: QRCodeScanningSession
7+
private var didHandleToken = false
78

89
init(view: QRLoginScanningView, parentCoordinator: QRLoginParentCoordinator, cameraSession: QRCodeScanningSession = QRLoginCameraSession()) {
910
self.view = view
@@ -48,6 +49,9 @@ extension QRLoginScanningCoordinator {
4849
}
4950

5051
func didScanToken(_ token: QRLoginToken) {
52+
guard !didHandleToken else { return }
53+
didHandleToken = true // Prevents the subsequent captures.
54+
5155
parentCoordinator.track(.qrLoginScannerScannedCode)
5256

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

0 commit comments

Comments
 (0)