1

With a phpMySQL background, I'm a little bit lost.

I've successfully created a registration process with Flutter and Firebase Auth (simple email/password method) following a tutorial.

I would like add a "username" and "age" field to the registration form.

In Firebase I've created a database called "users", and in it a String typed "userid" that's blank. But is it even necessary? What do I do next? How is it mapped to the User UID in the authentication table? How do I push it and retrieve it with Flutter?

I've explored this post to no avail Add extra User Information with firebase

If that helps, my authentication file contains this:

class Auth implements BaseAuth {
  final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;

  Future<String> signIn(String email, String password) async {
    FirebaseUser user = await _firebaseAuth.signInWithEmailAndPassword(
        email: email, password: password);
    return user.uid;
  }

  Future<String> signUp(String email, String password) async {
    FirebaseUser user = await _firebaseAuth.createUserWithEmailAndPassword(
        email: email, password: password);
    return user.uid;
  }

Have tried this:

Future<String> signUp(String email, String password) async {
    FirebaseUser user = await _firebaseAuth.createUserWithEmailAndPassword(
        email: email, password: password);

    Firestore.instance.collection('users').document().setData({ 'userid': user.uid, 'displayName': 'bobby' });

    return user.uid;
  }

But it throws an error:

5.17.0 - [Firebase/Firestore][I-FST000001] Write at users/-L_6e1CFkU1YchxsSPay failed: Missing or insufficient permissions.

1 Answer 1

0

Ok seems the above is all good. Just had to change the Database rules from false to true as per the below post:

https://stackoverflow.com/a/46925637/3475894

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.