Set user properties as firebase-admin

1k Views Asked by At

I have following character creation flow for the game and use firebase-admin on the server to validate data, one issue I came across is figuring out how to add user property on the server, so here is the idea:

  • authenticated user sends character data to /queue/create
  • firebase-admin server listens for changes in this /queue/create
  • firebase-admin receives and validates the data for the character
  • if successful firebase-admin pushes new character data to /characters
  • [can't figure this one out] firebase-admin adds property to user like this user.updateProfile({ character: /* id of character node created by firebase-admin */ })

Issue here is that I have access to the user on the client, but not my admin server, yes I could set this up client side, but would rather keep such logic on the server. I am already passing uid along side character data during step 1, this is also added to a character node for further security validation.

Edit: a sub-question occurred to me while writing this, can we somehow handle user changing their own user profile data, as I believe this is possible?

2

There are 2 best solutions below

2
On BEST ANSWER

If you want to add properties (also known as "claims") to a user's profile, that is currently only possible when you mint your own tokens for that user.

For the standard providers, you can only update the existing properties from the admin SDK.

0
On

You can use the updateUser() method to update a Firebase Auth user's profile data from the Admin Node.js SDK.