working auth handler and listener and successfuly changing auth and all
This commit is contained in:
@@ -39,6 +39,8 @@ final class AuthSessionStore: ObservableObject, SessionStore {
|
||||
let clientID = FirebaseApp.app()?.options.clientID
|
||||
self.GIDconfig = GIDConfiguration(clientID: clientID!)
|
||||
|
||||
print(clientID)
|
||||
|
||||
self.setupAuthListen()
|
||||
}
|
||||
|
||||
@@ -113,12 +115,15 @@ final class AuthSessionStore: ObservableObject, SessionStore {
|
||||
|
||||
if let user = user {
|
||||
// if we have a user, create a new user model
|
||||
print("Got user: \(user)")
|
||||
print("Got user: \(user.displayName!)")
|
||||
self.user = User(
|
||||
_uid: user.uid, _email: user.email, _displayName: user.displayName, _profilePic: user.photoURL, _phoneNumber: user.phoneNumber)
|
||||
|
||||
self.sessionState = .isAuthenticated
|
||||
} else {
|
||||
// if we don't have a user, set our session to nil
|
||||
self.user = nil
|
||||
self.sessionState = .isLoggedOut
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,8 @@ import GoogleSignIn
|
||||
struct nirvana_iosApp: App {
|
||||
@StateObject var authSessionStore: AuthSessionStore = AuthSessionStore()
|
||||
|
||||
init() {
|
||||
self.setupAuth()
|
||||
}
|
||||
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
|
||||
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
@@ -24,8 +23,13 @@ struct nirvana_iosApp: App {
|
||||
}
|
||||
}
|
||||
|
||||
extension nirvana_iosApp {
|
||||
private func setupAuth() {
|
||||
FirebaseApp.configure()
|
||||
class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||
FirebaseApp.configure()
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
|
||||
return GIDSignIn.sharedInstance.handle(url)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user