Home > Blockchain >  How to set the `currentUser` in Firebase when using sessions/cookies for persistence?
How to set the `currentUser` in Firebase when using sessions/cookies for persistence?

Time:09-27

I'm using sessions/cookies to authenticate my Firebase users.

The persistence on the client is set to "none" (auth.setPersistence(inMemoryPersistence)) and I'm using admin.auth().verifySessionCookie() on the server to validate each request.

The issue is that on the client/browser, auth.currentUser is always null.

Normally I wouldn't care about auth.currentUser, because I'm sending all the user info I need from the server to the client anyway. But if I want to use @firebase/storage, then the user needs to be authenticated locally on the client in order to be able to upload files and match the security rules.

What mechanism should I use to be able to set the currentUser on the client?

  • Related