You have a Firebase Realtime Database rule that denies write access to a path. What is the result when a client tries to write data to that path?
rules_version = '2'; service firebase.database { match /{database}/ { match /users/{userId} { allow write: if false; } } }
Think about what happens when rules explicitly deny access.
If a rule denies write access, Firebase rejects the write immediately and returns a permission denied error to the client. The data is not saved.
In Firebase Realtime Database rules, which condition correctly checks if the user is signed in?
Firebase uses a special variable to represent authentication info.
The variable auth is null if the user is not signed in. Checking auth != null confirms the user is authenticated.
You want to write a Firebase Realtime Database rule that allows writes only if the 'score' field is an integer from 0 to 100 inclusive. Which rule condition achieves this?
Use Firebase's newData.child('field').isNumber() and val() methods.
Option B correctly checks that 'score' exists, is a number, and is between 0 and 100 inclusive. Other options either use invalid syntax or wrong range checks.
What security risk arises if you set Firebase Realtime Database rules to allow read, write: if true;?
rules_version = '2'; service firebase.database { match /{database}/{document=**} { allow read, write: if true; } }
Consider what 'if true' means for access control.
Setting rules to 'if true' means no restrictions. Anyone on the internet can read or write any data, which is a major security risk.
You have a Firebase Realtime Database /users where each child key is a user's UID. Which rule correctly allows users to read and write only their own data?
rules_version = '2'; service firebase.database { match /{database}/ { match /users/{userId} { allow read, write: if auth != null && auth.uid == userId; } } }
Match the authenticated user ID with the document ID.
Option A restricts access so users can only read and write their own data by comparing auth.uid with the path variable userId. Other options are too open or incorrect.