12.5.3. Implementing Sign In
//
// RightBarButtonManager.swift
// App12
//
// Created by Sakib Miazi on 6/2/23.
//
import UIKit
import FirebaseAuth
extension ViewController{
func setupRightBarButton(isLoggedin: Bool){
//code omitted...
}
@objc func onSignInBarButtonTapped(){
//codes omitted...
//MARK: Sign In Action...
let signInAction = UIAlertAction(title: "Sign In", style: .default, handler: {(_) in
if let email = signInAlert.textFields![0].text,
let password = signInAlert.textFields![1].text{
//MARK: sign-in logic for Firebase...
self.signInToFirebase(email: email, password: password)
}
})
//codes omitted...
}
//codes omitted...
func signInToFirebase(email: String, password: String){
//MARK: can you display progress indicator here?
//MARK: authenticating the user...
Auth.auth().signIn(withEmail: email, password: password, completion: {(result, error) in
if error == nil{
//MARK: user authenticated...
//MARK: can you hide the progress indicator here?
}else{
//MARK: alert that no user found or password wrong...
}
})
}
}

App12 code so far:
Last updated