-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignViewModel.swift
53 lines (42 loc) · 1.06 KB
/
SignViewModel.swift
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
46
47
48
49
50
51
52
53
//
// ViewModel.swift
// EngAttack
//
// Created by mosi on 5/1/24.
//
// ViewModel.swift
// LoginSignIn
//
// Created by mosi on 5/1/24.
//
import SwiftUI
import Firebase
import Foundation
import FirebaseAuth
@MainActor
final class SignViewModel : ObservableObject {
@Published var uid = ""
@Published var email = ""
@Published var password = ""
@Published var Signstate :SignInState = .signedOut
@Published var currentUser: Firebase.User?
enum SignInState {
case signedIn
case signedOut
}
init() {
currentUser = Auth.auth().currentUser
}
func signIn() async throws {
try await AuthenticationManager.shared.signInUser(email: email, password: password)
print("로그인 완료")
}
func signUp() async throws {
try await AuthenticationManager.shared.createUser(email: email, password: password)
}
func signOut() throws {
try AuthenticationManager.shared.signOut()
currentUser = nil
print("로그아웃 완료")
}
}