I updateProfile with a display name. I then try to access this display name in the database security rules. But the displayName on the database is not updated.
This is using Firebase realtime DB with Flutter.
Code:
await referencedData.firebaseAuth.currentUser.updateProfile(
displayName: 'gameName' //that only the players know about
);
In my rules I have:
".write": "!data.exists() ||
auth.displayName == data.child('gamename').val()",
//rules meaning no data exists, so owner can create a new game or
//game name already set in database, I know this gamename, and it is in display name, so I can write and delete
I have spent 3 days or more searching for documentation or examples. Any ideas on where to look?
All properties are available under auth.token
, and the display name is available under auth.token.name
.
So:
".write": "!data.exists() ||
auth.token.name == data.child('gamename').val()",
Also see the Firebase reference documentation for auth.token
.