To recap, we need to create a sign up process using password and Google provider. We need to keep all user management on Firebase. We need to add role admin
, and bloodType
attributes for every user.
One thing to keep in mind as we maneuver our way through Firebase Auth, you can get the token only on the client side, and you can set claims only on the server side.
Let’s begin with the server routes, and see how we can set custom claims.
I had to ditch StackBlitz for this project, find the code final code on GitHub.
Setting custom claims
The page that user signs in, should have the extra field in it for bloodType
. Let’s create an API route for it: POST /api/user
Read on Sekrab Garage