benwinding / react-admin-firebase

A firebase data provider for the react-admin framework
https://benwinding.github.io/react-admin-firebase/
MIT License
460 stars 175 forks source link

The reason for a failure to login using Firebase Auth isn't accessible by the caller #270

Open paulvonallwoerden opened 1 year ago

paulvonallwoerden commented 1 year ago

Current Behaviour

The underlying Firebase Auth errors thrown by the firebase package are silenced and a generic error is throws. Example:

    import { useLogin } from 'react-admin'

    const login = useLogin()
    await login({ username: 'invalid', password: 'credentials' })    

the error thrown by the login method is a generic js-Error with the message Login error: invalid credentials. The original error by the Firebase Sdk is silenced.

See: https://github.com/benwinding/react-admin-firebase/blob/e3b1c01b368328935fcf82bd812207ed86d83fa8/src/providers/AuthProvider.ts#L26-L44

Expected Behaviour

The underlying Firebase error should be catchable to be able to make more informed decisions about the error. E.g. the error could be a auth/user-not-found as the user may have been deleted.

I propose the just re-throw the original Firebase error or at least offer a way to access it (e.g. using verror).