Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error.credential is null if credential-already-in-use #1329

Closed
sowdri opened this issue Jul 23, 2018 · 4 comments
Closed

error.credential is null if credential-already-in-use #1329

sowdri opened this issue Jul 23, 2018 · 4 comments
Assignees
Milestone

Comments

@sowdri
Copy link
Contributor

sowdri commented Jul 23, 2018

Summary:

According to the docs, if the linkWithCredential fails, then the error should contain error.credential which should be used in the subsequent call to signInWithCredential, but it's null.

Quoted from the docs:

auth/credential-already-in-use: Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User. For example, this error could be thrown if you are upgrading an anonymous user to a Google user by linking a Google credential to it and the Google credential used is already associated with an existing Firebase Google user. The fields error.email, error.phoneNumber, and error.credential (AuthCredential) may be provided, depending on the type of credential. You can recover from this error by signing in with error.credential directly via auth#signInWithCredential.

I'm using phone auth with anonymous login. So all users are authenticated anonymously at first, and during login, are linked with the credentials created using phone number and sms code. This works fine for new mobile numbers, however when the mobile number already exists, the linking fails, and I've to signInWithCredential instead, which is not possible at the moment, because the error.credential is null.

Any help is appreciated,
Thanks,

@Salakar Salakar added plugin: authentication Firebase Authentication help: needs-triage Issue needs additional investigation/triaging. labels Jul 23, 2018
@Salakar Salakar self-assigned this Jul 23, 2018
@barbarosh
Copy link

@Salakar Salakar added this to the v5.0.0 Release milestone Aug 4, 2018
@Salakar
Copy link
Member

Salakar commented Aug 4, 2018

@barbarosh the problem at the moment is that PhoneAuthCredentials aren't serializable both ways across the bridge, at least not on Android - @sowdri and I discussed this at length on the #authentication discord channel. We need to come up with a way of storing the token on the native side only and faking it on the JS side - with the real credential staying on native until it's consumed.

The second bigger issue is that React Native errors (through promise rejections on native code) can only provide string code and message properties - you cannot add extra properties, in this case, a credential or something referencing one, so we'd have to make all auth methods resolve for everything (even on exceptions) and and add code to detect if resolved data was an error or not in JS code, convert to a JS error and finally JS promise resolve/reject to userlands code - based on natives resolved value. Quite a big internal change.


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar added the Workflow: Needs Review Pending feedback or review from a maintainer. label Aug 4, 2018
@Salakar
Copy link
Member

Salakar commented Sep 1, 2018

Hey, not forgotten about this - I've been working on adding support in React Native for the second issue I mentioned above.

Have just sent up a PR to React Native - so once/if this lands in a version we can start getting this supported.

PR: facebook/react-native#20940


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar added blocked: react-native Issue or PR blocked by a React Native issue or change. and removed Workflow: Needs Review Pending feedback or review from a maintainer. labels Sep 1, 2018
@Salakar Salakar removed the help: needs-triage Issue needs additional investigation/triaging. label Sep 1, 2018
@Salakar Salakar modified the milestones: v5.0.0 Release, v6.0.0 Sep 20, 2018
@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label May 6, 2019
@invertase invertase deleted a comment from stale bot May 6, 2019
@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label May 6, 2019
@Salakar
Copy link
Member

Salakar commented May 6, 2019

Hey, closing this and tracking in the following PR:

#2107

Thanks

@Salakar Salakar closed this as completed May 6, 2019
@Salakar Salakar removed the blocked: react-native Issue or PR blocked by a React Native issue or change. label May 6, 2019
@invertase invertase locked as resolved and limited conversation to collaborators May 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants