I have an iOS app that checks whether a user is already logged in by checking Auth.auth().currentUser
. If this returns a non-null, the app 'automatically' logs the user into the app.
If I delete a user using Firebase admin tools, the iOS application will not know about the deletion. It will just check if Auth.auth().currentUser
exists and if it does, it 'automatically' logs in. However, what is happening is that despite the deletion of a user (an anonymous user), the user is able to create documents in the database.
I have security rules to prevent this:
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
match /{document=**} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
}
How is it possible for a nonexistent user to have request.auth != null
? The user does not exist in the "Authentication" tab.
Sure enough, if I reload the user it gives an error:
Auth.auth().currentUser.reload { error in }
There is no user record corresponding to this identifier. The user may have been deleted.