summaryrefslogtreecommitdiffstats
path: root/ios/Hæ-appen
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-04 00:17:16 +0100
committerivar <i@oiee.no>2025-12-04 00:17:16 +0100
commit724860c272afb7fe5a02645ef1c1b8d208d897f3 (patch)
treedf9b72b9cd9cc716ceb19a4a9085b8f1ba5b6972 /ios/Hæ-appen
parent401226a14f3e5ef98b959e818d37683afd7056d9 (diff)
downloadwhat-724860c272afb7fe5a02645ef1c1b8d208d897f3.tar.xz
what-724860c272afb7fe5a02645ef1c1b8d208d897f3.zip
POC auth in app
Diffstat (limited to 'ios/Hæ-appen')
-rw-r--r--ios/Hæ-appen/Auth.swift40
-rw-r--r--ios/Hæ-appen/ProfileContentView.swift28
-rw-r--r--ios/Hæ-appen/TabBarView.swift4
3 files changed, 70 insertions, 2 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()
+ }
+}
diff --git a/ios/Hæ-appen/ProfileContentView.swift b/ios/Hæ-appen/ProfileContentView.swift
new file mode 100644
index 0000000..af5cd33
--- /dev/null
+++ b/ios/Hæ-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æ-appen/TabBarView.swift b/ios/Hæ-appen/TabBarView.swift
index 2a88336..59896c5 100644
--- a/ios/Hæ-appen/TabBarView.swift
+++ b/ios/Hæ-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()
}
}
}