0

i have a problem with firebase authentication in flutter. Registration is successful, when i try to log in, after press login button, i have this error

W/Firestore(31652): (21.3.0) [Firestore]: Listen for Query(users/<...UID...>) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

I/flutter (31652): PlatformException(Error performing get, PERMISSION_DENIED: Missing or insufficient permissions., null)

Login button code is:

child: RaisedButton(
            child: Text("Login", style: TextStyle(
              fontSize: 18.0,
              fontFamily: 'MontserratBold',
            ),
            ),
            elevation: 5.0,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(30.0),
            ),
            color: Colors.white,
            textColor: Colors.black,
            padding: EdgeInsets.all(15.0),
            onPressed: () {
              if (_loginFormKey.currentState.validate()) {
                FirebaseAuth.instance
                    .signInWithEmailAndPassword(
                    email: emailInputController.text,
                    password: pwdInputController.text)
                    .then((currentUser) => Firestore.instance
                    .collection("users")
                    .document(currentUser.user.uid)
                    .get()
                    .then((DocumentSnapshot result) =>
                    Navigator.pushReplacement(
                        context,
                        MaterialPageRoute(
                            builder: (context) => HomePage(
                              uid: currentUser.user.uid,
                            ))))
                    .catchError((err) => print(err)))
                    .catchError((err) => print(err));
              }
            },
          ),

I also read that a possible solution is to change permissions in firebase, but in that case i allow any users to write and read or not ?

1 Answer 1

0

Make sure that you allow read and write in firebase database rules-

Firebase configuration

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

2 Comments

ok, but maybe it's not a secure solution. I've tryed to use "allow read, write: if request.auth != null" and works but is the best solution ? secure enough ?
@luc Looking at this Firestore Security link you seem to be on the right track. For a specified document (you can different rules for different documents in firestore) configure your rules for read and write to how you want it.

Your Answer

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