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

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

Open
paulvonallwoerden opened this issue Apr 2, 2023 · 0 comments

Comments

@paulvonallwoerden
Copy link

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:

public async HandleAuthLogin(params: { username: string; password: string }) {
const { username, password } = params;
if (username && password) {
try {
const user = await this.fireWrapper.authSigninEmailPassword(
username,
password
);
log('HandleAuthLogin: user sucessfully logged in', { user });
return user;
} catch (e) {
log('HandleAuthLogin: invalid credentials', { params });
throw new Error('Login error: invalid credentials');
}
} else {
return this.getUserLogin();
}
}

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant