Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Auth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!, completion: {
- (user, error) in
- // user's auth credentials are now created but user can still be nil
- Auth.auth().signIn(withEmail: self.emailTextField.text!, password: self.passwordTextField.text!, completion: {
- (user, error) in
- // user's auth credentials are now accessed but user can still be nil
- class FirebaseSingleton{
- static let sharedInstance = FirebaseSingleton()
- var dbRef: DatabaseReference? = Database.database().reference()
- var storageDbRef: StorageReference? = Storage.storage().reference(forURL: "gs://blablabla.appspot.com")
- var currentUser: User? = Auth.auth().currentUser
- var currentUserID: String? = Auth.auth().currentUser?.uid
- var currentUserEmail: String? = Auth.auth().currentUser?.email
- var currentUserPhotoUrl: URL? = Auth.auth().currentUser?.photoURL
- var currentUserDisplayName: String? = Auth.auth().currentUser?.displayName
- }
- Auth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!, completion: {
- (user, error) in
- if error != nil { return }
- if let user = user{
- let sharedInstance = FirebaseSingleton.sharedInstance
- sharedInstance.currentUser = user
- sharedInstance.currentUserID = user.uid
- sharedInstance.currentUserEmail = user.email // at this point is it possible for this to be nil?
- sharedInstance.currentUserPhotoUrl = user.photoURL
- sharedInstance.currentUserDisplayName = user.displayName
- }else{
- return
- }
- // is this guard statement necessary?
- guard let email = user.uid else { return }
- })
- Auth.auth().signIn(withEmail: emailTextField.text!, password: passwordTextField.text!, completion: {
- (user, error) in
- if error != nil { return }
- if let user = user{
- let sharedInstance = FirebaseSingleton.sharedInstance
- sharedInstance.currentUser = user
- sharedInstance.currentUserID = user.uid
- sharedInstance.currentUserEmail = user.email // at this point is it possible for this to be nil?
- sharedInstance.currentUserPhotoUrl = user.photoURL
- sharedInstance.currentUserDisplayName = user.displayName
- }else{
- return
- }
- // is this guard statements necessary?
- guard let email = user.uid else { return }
- })
Add Comment
Please, Sign In to add comment