Skip to content

Instantly share code, notes, and snippets.

@fredriccliver
Created October 9, 2021 06:08
Show Gist options
  • Save fredriccliver/578b48323cd5ccd65c46c911610c6eed to your computer and use it in GitHub Desktop.
Save fredriccliver/578b48323cd5ccd65c46c911610c6eed to your computer and use it in GitHub Desktop.
import UIKit
import FirebaseAuth
import Kingfisher
class NextVC: UIViewController {
@IBOutlet var profileImageView: UIImageView!
@IBOutlet var nameLabel: UILabel!
@IBAction func onLogoutButton(_ sender: UIButton) {
do{
try Auth.auth().signOut()
self.dismiss(animated: true, completion: nil)
}catch let err as NSError {
print(err)
}
}
override func viewDidLoad() {
super.viewDidLoad()
presentUserInfo()
}
func presentUserInfo(){
guard let user = Auth.auth().currentUser else {
print("user not logged in")
return
}
// print(user.isAnonymous)
/*
displayName
photoURL
email
isAnonymous
*/
profileImageView.kf.setImage(with: user.photoURL, placeholder: nil, options: nil) { result, error in
}
if(user.isAnonymous){
nameLabel.text = "Anonymous"
}else{
nameLabel.text = user.displayName
}
}
@IBAction func touchedLogoutButton(_ sender: UIButton) {
do {
try Auth.auth().signOut()
dismiss(animated: true, completion: nil)
} catch let signOutError as NSError {
print("Error signing out: %@", signOutError)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment