react-admin
react-admin copied to clipboard
Auth provider login Promise rejection with "message" doesn't trigger notification message
What you were expecting: Notification triggers when login func returns Promise.reject({message: 'Error notification'}); What happened instead: I got only an error message in the console. Steps to reproduce:
- Go to authProvider;
- return Promise.reject({message: 'Error notification'}) in "login" func. Related code:
login: async (params: LoginParams) => {
const request = new Request(`/auth/login`, {
method: 'POST',
body: JSON.stringify(
{
username: params.username,
password: params.password,
},
),
headers: new Headers({ 'Content-Type': 'application/json' }),
});
try {
const response = await fetch(request);
if (response.status < 200 || response.status >= 300) {
return Promise.reject({ message: 'Invalid credentials' });
}
const authResponse = await response.json();
if (!authResponse.accessToken) {
return Promise.reject({
message: 'Your account is not active yet. Please contact some of the admins to take access.',
});
}
cookies.set('AccessToken', authResponse.accessToken);
} catch (e) {
return Promise.reject({ message: 'Something went wrong. Please, try again.' });
}
}
Other information: https://marmelab.com/react-admin/doc/3.19/Authentication.html#:~:text=string%20%7C%20%7B%20message%3F%3A%20string%20%7D%20error%20message%20to%20display
Environment
- React-admin version: 4.16.12
- Last version that did not exhibit the issue (if applicable): -
- React version: 18.2.0
- Browser: latest chrome
Hi @olesmarola. I can't reproduce this in our demo. Would you mind building adding a repro to this issue?
No news for some time, closing.