diff options
Diffstat (limited to 'ios/Hæ-appen/Auth.swift')
| -rw-r--r-- | ios/Hæ-appen/Auth.swift | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ios/Hæ-appen/Auth.swift b/ios/Hæ-appen/Auth.swift new file mode 100644 index 0000000..09da4af --- /dev/null +++ b/ios/Hæ-appen/Auth.swift @@ -0,0 +1,40 @@ +// +// Auth.swift +// Hæ-appen +// +// Created by Ivar Løvlie on 03/12/2025. +// +import SwiftUI +import AuthenticationServices +import OSLog + +struct Auth { + let logger = Logger(subsystem: "com.yourcompany.app", category: "auth") + func login() -> Void { + guard let url = URL(string:"http://192.168.0.103:5281/login") else {return} + let session = ASWebAuthenticationSession(url: url, callbackURLScheme: "what") { + callbackURL, error in + guard error == nil, let callbackURL = callbackURL else { return } + let queryItems = URLComponents(string: callbackURL.absoluteString)?.queryItems + _ = queryItems?.filter({ $0.name == "code" }).first?.value + } + let vc = AuthViewController() + session.presentationContextProvider = vc + session.start() + return + } + func register() -> Void { + return + } + func logout() -> Void { + return + } + +} + +class AuthViewController: UIViewController, ASWebAuthenticationPresentationContextProviding +{ + func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { + return ASPresentationAnchor() + } +} |
