mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 14:13:45 +00:00
[ios] Switched OSM Oauth to using a link
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
126d4f6373
commit
090b7c21fc
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user