-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
TypeError: authProvider.checkAuth is not a function #5200
Comments
There is not enough information here to understand what you did. Please fork the codesandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple) and modify it to show the issue. |
No news for more than a month, closing. |
I can confirm this happens by following the Authentication tutorial. Apparently the code provided for the authProvider is incomplete (missing checkAuth): // in src/authProvider.js
const authProvider = {
login: ({ username, password }) => {
const request = new Request('https://mydomain.com/authenticate', {
method: 'POST',
body: JSON.stringify({ username, password }),
headers: new Headers({ 'Content-Type': 'application/json' }),
});
return fetch(request)
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
})
.then(auth => {
localStorage.setItem('auth', JSON.stringify(auth));
});
},
// ...
};
export default authProvider; |
yes you're right, the sample code is incomplete, probably intentionally since it would be pretty obvious;
please, note, that in order to build fully functioning, secure authenticator you may need to fully implement all those functions. |
The tutorial could be adapted as everyone comes back to this page. |
We would gladly accept a PR to fix it :) |
What you were expecting:
login pageWhat happened instead:
TypeError: authProvider.checkAuth is not a functionSteps to reproduce:
Only added App.js and authProvider.jsRelated code:
Other information:
Environment
The text was updated successfully, but these errors were encountered: