-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthService.swift
More file actions
45 lines (37 loc) · 1.13 KB
/
Copy pathAuthService.swift
File metadata and controls
45 lines (37 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// AuthService.swift
// DevLog
//
// Created by 최윤진 on 11/29/25.
//
import FirebaseAuth
import FirebaseFirestore
final class AuthService {
private let store = Firestore.firestore()
private let logger = Logger(category: "AuthService")
var uid: String? {
Auth.auth().currentUser?.uid
}
var providerIDs: [String]? {
Auth.auth().currentUser?.providerData.map { $0.providerID }
}
func getProviderID() async throws -> String? {
logger.info("Fetching current provider ID")
guard let uid = uid else {
logger.warning("No user ID available")
return nil
}
do {
let document = try await store
.collection("users/\(uid)/userData")
.document("info")
.getDocument()
let providerID = document.data()?["currentProvider"] as? String
logger.info("Successfully fetched provider ID: \(providerID ?? "nil")")
return providerID
} catch {
logger.error("Failed to fetch provider ID", error: error)
throw error
}
}
}