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--appen-Info.plist | 5 ++- "ios/H\303\246-appen.xcodeproj/project.pbxproj" | 17 --------- .../xcshareddata/swiftpm/Package.resolved" | 24 ++----------- "ios/H\303\246-appen/Auth.swift" | 40 ++++++++++++++++++++++ "ios/H\303\246-appen/ProfileContentView.swift" | 28 +++++++++++++++ "ios/H\303\246-appen/TabBarView.swift" | 4 +-- 6 files changed, 77 insertions(+), 41 deletions(-) create mode 100644 "ios/H\303\246-appen/Auth.swift" create mode 100644 "ios/H\303\246-appen/ProfileContentView.swift" (limited to 'ios') diff --git a/ios/H--appen-Info.plist b/ios/H--appen-Info.plist index 0c67376..121e93f 100644 --- a/ios/H--appen-Info.plist +++ b/ios/H--appen-Info.plist @@ -1,5 +1,8 @@ - + + CFBundleDocumentTypes + + diff --git "a/ios/H\303\246-appen.xcodeproj/project.pbxproj" "b/ios/H\303\246-appen.xcodeproj/project.pbxproj" index 89a4707..0d15cca 100644 --- "a/ios/H\303\246-appen.xcodeproj/project.pbxproj" +++ "b/ios/H\303\246-appen.xcodeproj/project.pbxproj" @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 1B9B791B2E7A06C300D5AF05 /* GISTools in Frameworks */ = {isa = PBXBuildFile; productRef = 1B9B791A2E7A06C300D5AF05 /* GISTools */; }; - 1B9E76382EA6DCD200170C86 /* MijickCamera in Frameworks */ = {isa = PBXBuildFile; productRef = 1B9E76372EA6DCD200170C86 /* MijickCamera */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,7 +27,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1B9E76382EA6DCD200170C86 /* MijickCamera in Frameworks */, 1B9B791B2E7A06C300D5AF05 /* GISTools in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -73,7 +71,6 @@ name = "Hæ-appen"; packageProductDependencies = ( 1B9B791A2E7A06C300D5AF05 /* GISTools */, - 1B9E76372EA6DCD200170C86 /* MijickCamera */, ); productName = "Hæ-appen"; productReference = 1B9B79032E79DFB800D5AF05 /* Hæ-appen.app */; @@ -105,7 +102,6 @@ minimizedProjectReferenceProxies = 1; packageReferences = ( 1B9B79192E7A06C300D5AF05 /* XCRemoteSwiftPackageReference "gis-tools" */, - 1B9E76362EA6DCD200170C86 /* XCRemoteSwiftPackageReference "Camera" */, ); preferredProjectObjectVersion = 77; productRefGroup = 1B9B79042E79DFB800D5AF05 /* Products */; @@ -373,14 +369,6 @@ minimumVersion = 1.3.0; }; }; - 1B9E76362EA6DCD200170C86 /* XCRemoteSwiftPackageReference "Camera" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/Mijick/Camera.git"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 3.0.3; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -389,11 +377,6 @@ package = 1B9B79192E7A06C300D5AF05 /* XCRemoteSwiftPackageReference "gis-tools" */; productName = GISTools; }; - 1B9E76372EA6DCD200170C86 /* MijickCamera */ = { - isa = XCSwiftPackageProductDependency; - package = 1B9E76362EA6DCD200170C86 /* XCRemoteSwiftPackageReference "Camera" */; - productName = MijickCamera; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 1B9B78FB2E79DFB800D5AF05 /* Project object */; diff --git "a/ios/H\303\246-appen.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" "b/ios/H\303\246-appen.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" index 8b323a8..e4a6dc8 100644 --- "a/ios/H\303\246-appen.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" +++ "b/ios/H\303\246-appen.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" @@ -1,31 +1,13 @@ { - "originHash" : "632a8f8853aa0d419765a7b78fcd66e62b7f9aa58329c89492d24f6985316ee5", + "originHash" : "a1cca039aa1704ebabd161056262205e26a4daf8a42ebb77bc98b0b620ee8fb4", "pins" : [ - { - "identity" : "camera", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Mijick/Camera.git", - "state" : { - "revision" : "0f02348fcc8fbbc9224c7fbf444f182dc25d0b40", - "version" : "3.0.3" - } - }, { "identity" : "gis-tools", "kind" : "remoteSourceControl", "location" : "https://github.com/Outdooractive/gis-tools.git", "state" : { - "revision" : "f7a4d2aa2acf771b79a91150f359bcd84de9ceac", - "version" : "1.13.2" - } - }, - { - "identity" : "timer", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Mijick/Timer", - "state" : { - "revision" : "342371c33c3f084d82a4818447ba77d858064c85", - "version" : "2.0.0" + "revision" : "30e1e1f0af115822e5844792f2322107c81b2c5e", + "version" : "1.3.0" } } ], 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