Lukas Lukac
Lukas Lukac

Reputation: 8346

firebase multiple providers storing user id

if i would like to have two registration providers (password, facebook). What is the best way to store user's id?

In this comment kato says that firebase provides unique uid.

But the uids looks like:

uid: facebook:10000000477077
uid: simplelogin:48

Currently i have /users/< id >

And now i would have /users/< uid > ? like /users/facebook:10000000477077 ?

Is that good from performance view or am i missing something? Because better then this uid would be even an unique username or not?

Thank you.

Upvotes: 1

Views: 341

Answers (1)

Rob DiMarco
Rob DiMarco

Reputation: 13266

While the id attribute is the id for the specified provider, but the uid, as you mention, is unique across all providers. There's no negative performance impact for using these attributes for your user ids, and is recommended if you are allowing users to log in across many different providers.

Alternatively, you could store your users as /users/<provider>/<id>, such as /users/facebook/12345 which also addresses the concern around collisions.

Upvotes: 1

Related Questions