1

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?

Ilja
  • 44,142
  • 92
  • 275
  • 498

2 Answers2

1

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thank you, I believe if I create new user property on client side so I am then able to update it on admin, works? Or use display name as a hacky solution for this – Ilja Feb 25 '17 at 17:09
  • 1
    There is no way to add properties to the existing providers. You can of course re-use an existing property, but I have no recommendation for or against that. – Frank van Puffelen Feb 25 '17 at 17:21
0

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

jwngr
  • 4,284
  • 1
  • 24
  • 27