Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AuthManager {
- static let shared = AuthManager()
- let supabaseClient = SupabaseClient(
- supabaseURL: URL(string: Environment.supabaseURL)!,
- supabaseKey: Environment.supabaseAnonKey
- )
- func addUserFullName(_ fullName: String) async throws {
- guard !fullName.isEmpty else { return }
- let attributes = UserAttributes(data: ["fullName": AnyJSON.string(fullName)])
- try await supabaseClient.auth.update(user: attributes)
- }
- func supabaseSignIn(idToken: String, nonce: String, fullName: String) async throws {
- do {
- let _ = try await supabaseClient.auth.signInWithIdToken(
- credentials: .init(provider: .apple, idToken: idToken, nonce: nonce)
- )
- try await addUserFullName(fullName)
- } catch {
- print("Supabase sign in failed: \(error)")
- throw error
- }
- }
- @MainActor
- func supabaseSignOut() async {
- try? await supabaseClient.auth.signOut()
- TransitionManager.shared.transitionToLogin()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment