[ios] Switched OSM Oauth to using a link

Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
Yannik Bloscheck
2025-06-24 16:39:25 +02:00
committed by Konstantin Pastbin
parent 126d4f6373
commit 090b7c21fc
11 changed files with 98 additions and 25 deletions

View File

@@ -130,9 +130,25 @@
// Not supported on iOS.
return false;
case .oAuth2:
// TODO: support OAuth2
return false;
var components = url.absoluteString.components(separatedBy: "cm://oauth2/osm/callback?code=")
components.removeAll { component in
component.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}
if let code = components.first {
Bridging.saveOauthToken(from: code)
let window = (UIApplication.shared.connectedScenes.filter { $0.activationState == .foregroundActive }.first(where: { $0 is UIWindowScene }) as? UIWindowScene)?.keyWindow
window?.rootViewController?.presentedViewController?.navigationController?.popToRootViewController(animated: true)
window?.rootViewController?.presentedViewController?.dismiss(animated: true)
return true
} else {
return false
}
case .incorrect:
if url.absoluteString.starts(with: "cm://oauth2/osm/callback") {
let window = (UIApplication.shared.connectedScenes.filter { $0.activationState == .foregroundActive }.first(where: { $0 is UIWindowScene }) as? UIWindowScene)?.keyWindow
window?.rootViewController?.presentedViewController?.navigationController?.popToRootViewController(animated: true)
window?.rootViewController?.presentedViewController?.dismiss(animated: true)
}
// Invalid URL or API parameters.
return false;
@unknown default: