-
Notifications
You must be signed in to change notification settings - Fork 156
Open
Description
When you bootstrap a new refine project using the refine command line tool and select Strapi v4 as Data Provider, a src/authProvider.ts file is created. Of particular interest is the login method of the authProvider. Notice how the username field is being destructured. When you console.log(username), you will get undefined. I suspect it has something to do with use of AuthPage instead of LoginPage (which is now deprecated).
You should be destructuring email instead. I feel a beginner might find it difficult to see what is going on.
export const authProvider: AuthProvider = {
login: async ({ username, password }) => {
const { data, status } = await strapiAuthHelper.login(username, password);
// console.log(username) undefined
if (status === 200) {
localStorage.setItem(TOKEN_KEY, data.jwt);
// set header axios instance
axiosInstance.defaults.headers.common = {
Authorization: `Bearer ${data.jwt}`,
};
return Promise.resolve();
}
return Promise.reject();
},
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels