From 724860c272afb7fe5a02645ef1c1b8d208d897f3 Mon Sep 17 00:00:00 2001 From: ivar Date: Thu, 4 Dec 2025 00:17:16 +0100 Subject: POC auth in app --- "ios/H\303\246-appen/Auth.swift" | 40 ++++++++++++++++++++++++++ "ios/H\303\246-appen/ProfileContentView.swift" | 28 ++++++++++++++++++ "ios/H\303\246-appen/TabBarView.swift" | 4 +-- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 "ios/H\303\246-appen/Auth.swift" create mode 100644 "ios/H\303\246-appen/ProfileContentView.swift" (limited to 'ios/Hæ-appen') diff --git "a/ios/H\303\246-appen/Auth.swift" "b/ios/H\303\246-appen/Auth.swift" new file mode 100644 index 0000000..09da4af --- /dev/null +++ "b/ios/H\303\246-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() + } +} diff --git "a/ios/H\303\246-appen/ProfileContentView.swift" "b/ios/H\303\246-appen/ProfileContentView.swift" new file mode 100644 index 0000000..af5cd33 --- /dev/null +++ "b/ios/H\303\246-appen/ProfileContentView.swift" @@ -0,0 +1,28 @@ +// +// ProfileContentView.swift +// Hæ-appen +// +// Created by Ivar Løvlie on 03/12/2025. +// + +import SwiftUI + +struct ProfileContentView : View { + let auth = Auth() + + var body: some View { + VStack { + Text("Halla!") + .font(.largeTitle) + HStack + { + Button("Logg på", systemImage: "hand.raised.square.on.square") { + auth.login() + } + Button("Registrer deg", systemImage: "hand.raised.square.on.square") { + auth.register() + } + }.buttonStyle(.borderless) + } + } +} diff --git "a/ios/H\303\246-appen/TabBarView.swift" "b/ios/H\303\246-appen/TabBarView.swift" index 2a88336..59896c5 100644 --- "a/ios/H\303\246-appen/TabBarView.swift" +++ "b/ios/H\303\246-appen/TabBarView.swift" @@ -16,8 +16,8 @@ struct TabBarView : View { Tab("Resten", systemImage: "option") { MapContentView() } - Tab("", systemImage: "camera.shutter.button.fill", role: .search) { - CameraContentView() + Tab("Profil", systemImage: "person", role: .search) { + ProfileContentView() } } } -- cgit v1.3