Skip to content

FR: Retain anonymous user credentials after non-anonymous sign in #6194

@willbattel

Description

@willbattel

Feature proposal

  • Firebase Component: Auth

Our app does not force users to sign in with a non-anonymous provider when they use the app. Instead, we authenticate them anonymously until they choose to sign in, allowing them to securely interact with Cloud Firestore and Cloud Functions as needed.

After signing into a non-anonymous provider, the user can at any later date choose to sign out. When this happens, the user has two choices: they can either sign into a different non-anonymous account, or they can proceed anonymously as they did originally before the initial non-anonymous sign in.

When anonymous users sign into non-anonymous accounts, the current Firebase SDK discards their anonymous credentials and abandons the account. This probably has little impact in most apps. However, in our app, we would really like it if the FIRAuth module could be configured to instead retain the anonymous credentials, so that the user could sign back into their original anonymous account, instead of needing to create a new anonymous account.

The reason this is important to us is because, in our app, we treat devices as first class citizens- meaning that some user generated content is associated with the device instead of the user. Users can link multiple devices together by signing into a non-anonymous provider- but devices can also stand alone with anonymous authentication. When users occasionally sign out of a non-anonymous provider, we don't want to have to create a new anonymous account. It would be fantastic if the Firebase SDK could retain the dormant anonymous credentials alongside the non-anonymous credentials if present, so that they could be re-activated later if desired.

Perhaps the signInAnonymously function could have a parameter added that opts into this functionality, such that if the flag is set to true: the previous anonymous account will be signed back into, and if set to false (default value and current SDK functionality): a new anonymous account will be created and signed into.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions