I’m a little confused by the user authentication implemented in the tutorial and the security rules for the realtime database.
If the app was in the AppStore wouldn’t all users be using the same grocery list? Any user seems able to gain access to the list by registering an email/password. How could I restrict login to say family and friends?
Or am I missing the point completely? Is this implementation of the database ‘public’ by design and not suited to simply letting a single user or a small defined group access their own data?
Actually, in your Registering Users section something should be changed. The Auth.auth().createUser(withEmail:password:) automatically signs in a user upon successful account creation. So practically you don’t need to call Auth.auth().signIn(withEmail:password:) there. And I believe this is due to change in firebase authentication design change but not at the time of writing this tutorial for the first time. More on Create a password-based account
Normally, you would implement Auth differently. We only made everything public for simplicity in this tutorial. You can restrict access such that a user can only see their collection for example.
Mikael, maybe the reader would understand that you have to exit XCode before doing a ‘pod install’ but you should really say so expressly, and that one loads the .xcworkspace file thereafter.
Thanks for the concerns. This is an intermediate tutorial and we decided to assume the reader knows how to use CocoaPods. There are many online tutorials about this including the official site.
Hey @kmikael thanks a lot for a great tutorial!
May I ask you how we would Update and existing cell with Firebase? I am kinda struggling on figuring that out.
Any info is greatly appreciated,
Thanks!
Hi there. Thanks for the awesome tutorial! I am struggling to understand how in LoginViewController.swift you manage to call performSegue() within viewDidLoad, before the view is totally loaded and visible? Is this something to do with Firebase?Thank you
SOLVED: For Registering Users, users are only added to Firebase when the password is minimum of 6 characters!. If you put in less than 6 characters, users will not be added to the Firebase user panel.
I believe the section, Registering Users, should be updated. I followed your instructions and do not see any new users being registered in my Firebase Authentication panel. I am able to add items to the list and see the effects immediately so that’s fine, but the same doesnt happen for when I try to sign up new users. Another user above, nayem, made similar mention of this as well.
And yes, I have Email/Password enabled in the Authentication > Sign-in Method panel.
Code in LoginViewController.
@IBAction func signUpDidTouch(_ sender: AnyObject) {
let alert = UIAlertController(title: "Register",
message: "Register",
preferredStyle: .alert)
let saveAction = UIAlertAction(title: "Save", style: .default) { _ in
// 1
let emailField = alert.textFields![0]
let passwordField = alert.textFields![1]
// 2
Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!) { user, error in
if error == nil {
// 3
Auth.auth().signIn(withEmail: self.textFieldLoginEmail.text!,
password: self.textFieldLoginPassword.text!)
}
}
}
.....