Mario
 · Developer

[Resolved] Can't do login with new user account

Database & APIs
Resolved

EDIT Problem Solved:

The issues were coming from Firebase Database Rules. Finally i can create new users with custom secure rules:

(These rules only allow propietary users to read & write they own user document).

match /users/{document} {

allow create: if request.auth.uid == request.resource.data.uid;

allow read: if request.auth.uid == document || request.auth.token.admin == true;

allow write: if request.auth.uid == resource.data.uid || request.auth.token.admin == true;

allow delete: if false;

}

The 'create' condition only allows if the user 'uid' matches the field 'uid' on the new created document. So no one can create a false user document.

The 'read' condition only allows to read the document if the user 'uid' that request matches with the 'document' name. (Assuming that you don't use any custom name for documents, and let Firebase create the document with your 'uid' by name.

The 'write' condition only allows if the user 'uid' that request matches with the field 'uid' that's already saved in the document.

Never allowing to 'delete' anything.

The '|| request.auth.token.admin == true' acts as a 'OR' condition. This is a custom claim for firebase to allowing 'admins' to read & write over all documents. But that's another story.

==================================================

Hello mates,

yesterday a faced a new error and for now i've been 5 hours trying to solve, but there's no way.

So, my app was working well (in fact, the app continue to work well, the problem it's just with the login).

Yesterday i just wanted to try to login with a new google account (using Google as provider). And for my surprise, the 'login button' was trying to do something , but the screen never navigated to the next one.

So i checked the 'Authentication Users List' on Firebase, and everything seems OK, the new google account it's inside the list, with his own UID.

Then i notice that the '/users/' collection Document (that should be created automatically when a new user login for the first time) was missing. Why is missing? (i started panicking)

I take a look at DevTools on Chrome, and i found a 'Permissions denied' error. (i started to turn crazy).

So from this very moment, i started to play with firebase rules. I don't know why, because all was running fine.

My Firebase Rules looks like that:

match /users/{document} {
      allow create: if request.auth.uid == document;
      allow read: if request.auth.uid == resource.data.uid || request.auth.token.admin == true;
      allow write: if request.auth.uid == resource.data.uid || request.auth.token.admin == true;
      allow delete: if false;
    }

I also saw that some users are facing very related problems with login:

https://community.flutterflow.io/ask-the-community/post/i-can-t-register-to-my-app-ne2sEW618VO98G6

https://community.flutterflow.io/ask-the-community/post/login-with-google-wtiRT9WuVRQ3z9h

Is there anything that FF has changed recently and may caused this?

Thanks.

What have you tried so far?

Change the firebase rules (even allowing all for creation):

allow create: if true;

allow create: if request.auth != null

but continues to throw permissions denied.

Did you check FlutterFlow's Documentation for this topic?
Yes
1
3 replies