deal-io / deal.io_producer

The frontend for deal.io producers.
3 stars 0 forks source link

Authstate Login Function Does not Work #26

Closed LeviOrtega closed 1 year ago

LeviOrtega commented 1 year ago

Authstate contains the function

func login(email: String, password: String) -> String? {
        do {
            // Attempt to authenticate the user with Firebase
            try Auth.auth().signIn(withEmail: email, password: password)
            // If authentication succeeds, set isLoggedIn to true and return nil
            self.isLoggedIn = true
            return nil
        } catch {
            // If authentication fails, return an error message
            return "Invalid email or password."
        }
    }

Which when called from a button, will not work. My theory is that is is needing to use Dispach.Async or something, but I don't know.

LeviOrtega commented 1 year ago

To get around this, i have just been calling

SubmitButton{Auth.auth().signIn(withEmail: email, password: password) { result, error in
                if let error = error {
                    // Handle login error
                    errorMessage = "Invalid Email or Password, try again."
                } else {
                    // Login successful
                    authState.isLoggedIn = true
                }

within LoginView, but I want to move this functionality over to AuthState