feathers
feathers copied to clipboard
Distinguishing an unsuccessful OAuth flow
Steps to reproduce
- a feathersjs backend and a react (web) frontend using feathersjs/client for authentication
- using feathersjs/authentication-local
- using feathersjs/authentication-oauth (google, in this case)
- calling .reAuthenticate() on frontend init to either:
- read token saved in localstorage or
- get oauth accessToken from location.hash
- get oauth error from location.hash
Actual behavior
Currently, the feathers client throws a 401 not-authenticated for both...
- when reAuthenticate does not find a token in localstorage (normal occurrence for every pageload for a non-logged-in user)
- when reAuthenticate captures an OAuth error from the location.hash, returning from an oauth flow
Expected behavior
It would be useful if there was a way to distinguish the OAuth failure error specifically (for example: an Oauth attempts to create a user that fails validation because the email already exists as a local-auth user ) and show the user some helpful info for logging in to their original account with email/password.
It's also very possible I'm thinking about this in completely the wrong way and there's a simpler way to detect a bad OAuth on the client. Thanks so much for your help!
Module versions (especially the part that's not working): 5.0.0-pre.3
NodeJS version: 14.15.0
Operating System: MacOS 11.3
Browser Version: Chrome 90.0.4430.61