gladly-team / next-firebase-auth

Simple Firebase authentication for all Next.js rendering strategies
https://nfa-example-git-v1x-gladly-team.vercel.app/
MIT License
1.34k stars 291 forks source link

Blocking functions not working #552

Closed tombouquet closed 1 year ago

tombouquet commented 1 year ago

Describe the bug When blocking functions are enabled, authentication fails. In my case I was returning 'sessionClaims' to the user (see https://firebase.google.com/docs/auth/extend-with-blocking-functions#modifying_a_user).

Blocking functions DO work however when using the Firebase emulators.

Versions

next-firebase-auth version: 0.14.4 Firebase JS SDK: 8.9.1 Next.js: 12.2.3

To Reproduce Steps to reproduce the behavior:

Note that I first discovered this on my own project which is on the latest versions of Firebase & the v1.0.0-canary.17 version of next-firebase-auth - however moved over to the example project to eliminate variables

  1. Download example project & hook up to your own Firebase project
  2. Create blocking function (either both or one doesn't matter)
  3. Try and login to the example app

Expected behavior The user should login with the proper returned user object. (basically it should work ah)

Debug and error logs

 [ 47.664s] [firebaseui] setAccountInfo: {"code":"auth/internal-error-encountered.","customData":{},"name":"FirebaseError"} <empty string> next-dev.js:24:25
Screen Shot 2022-09-06 at 5 20 56 pm
kmjennison commented 1 year ago

@RustedBuckett Does this still happen if you remove next-firebase-auth from the project entirely? I'd like to confirm it's not some other error with Firebase or Firebase UI.

tombouquet commented 1 year ago

After removing next-firebase-auth the problem still occurred. I found that the problem had to do with returning custom claims on a sign in method that didn't support it. (https://firebase.google.com/docs/auth/extend-with-blocking-functions#supported_credentials)