Using firebase adapter + firebase security rules #4293
Unanswered
DiegoGonzalezCruz
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm using firebase + nextauth, and I'm having issues authenticating my users in firebase.
At the moment, I'm passing the custom token generated in the jwt callback, to the session callback, and using useEffect in my redirection page to autheticate the user in firebase.
async jwt({ token, user, account, profile, isNewUser }) { if (isNewUser || user) { const additionalClaims = { isStudent: true, isTeacher: false, isStaff: false, isAdmin: false } const customToken = await adminAuth.createCustomToken(token.sub, additionalClaims) console.log(customToken, '***customToken') token.customToken = customToken } return token }, async session({ session, token, user }) { if (session?.user) { session.user.id = token.sub session.customToken = token.customToken } return session },
If I set the rules as 'request.auth !== null', then users can't sign In, as in the process of signing in, the adaptator create documents without being authenticated.
any lights about it? I'm totally losts.
Beta Was this translation helpful? Give feedback.
All reactions