absent-sapphire
absent-sapphire5mo ago

Login/ Register auth

Hello, im following this tutorial https://youtu.be/6a3Dz8gwjdg. Everything was working fine until i opened my project and there is an update. Since then i cant login nor register. If someone can help me it would be great ! This is the source code if needed. https://github.com/adrianhajdin/refine_dashboard/blob/main/src/providers/auth.ts
JavaScript Mastery
YouTube
Build and Deploy a React Admin Dashboard With Real time Data, Chart...
Build an admin dashboard with full authentication, a homepage displaying charts and activities, a comprehensive table for companies with CRUD and search, and a Kanban board with real-time synchronization using Refine Framework. ⭐ Refine: https://github.com/refinedev/refine ‎💻 App Source Code and Readme (code snippets at the bottom): https://git...
GitHub
refine_dashboard/src/providers/auth.ts at main · adrianhajdin/refin...
Build an admin dashboard with full authentication, a homepage displaying charts and activities, a comprehensive table for companies with CRUD and search, and a Kanban board with real-time synchroni...
No description
No description
2 Replies
kapa.ai
kapa.ai5mo ago
Hi @REAPER. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry to hear that you're having trouble with the login and register functionality after an update. Based on the information provided in the knowledge sources, there are a few things you could check: 1. AuthProvider: Ensure that your authProvider is correctly set up. It should include methods for login, logout, checkError, checkAuth, and getPermissions. Here's an example of how it could look:
export const authProvider: AuthProvider = {
login: async () => {
return Promise.resolve();
},
logout: () => {
localStorage.removeItem(TOKEN_KEY);
return Promise.resolve();
},
checkError: () => Promise.resolve(),
checkAuth: async () => {
let response = await axiosInstance.get("/api/auth")
if (!(response.status === 200)) {
const error = response.statusText;
return Promise.reject(error);
}
return Promise.resolve();
},
getPermissions: () => Promise.resolve(),
};
export const authProvider: AuthProvider = {
login: async () => {
return Promise.resolve();
},
logout: () => {
localStorage.removeItem(TOKEN_KEY);
return Promise.resolve();
},
checkError: () => Promise.resolve(),
checkAuth: async () => {
let response = await axiosInstance.get("/api/auth")
if (!(response.status === 200)) {
const error = response.statusText;
return Promise.reject(error);
}
return Promise.resolve();
},
getPermissions: () => Promise.resolve(),
};
(Source: Github Issue 2183 (https://github.com/refinedev/refine/issues/2183)) 2. Register Method: If you're having trouble with registration, make sure your register method in the authProvider is correctly set up. Here's an example:
register: async ({ email, password }) => {
try {
const { data, error } = await supabaseClient.auth.signUp({
email,
password,
});

if (error) {
return {
success: false,
error,
};
}

if (data) {
return {
success: true,
redirectTo: "/",
};
}
} catch (error: any) {
return {
success: false,
error,
};
}
return {
success: false,
error: {
message: "Register failed",
name: "Invalid email or password",
},
};
},
register: async ({ email, password }) => {
try {
const { data, error } = await supabaseClient.auth.signUp({
email,
password,
});

if (error) {
return {
success: false,
error,
};
}

if (data) {
return {
success: true,
redirectTo: "/",
};
}
} catch (error: any) {
return {
success: false,
error,
};
}
return {
success: false,
error: {
message: "Register failed",
name: "Invalid email or password",
},
};
},
(Source: Github Issue 4204 (https://github.com/refinedev/refine/issues/4204)) 3. Update Refine: Ensure that you're using the latest version of Refine. You can update it using this command: npm i @refinedev/cli@latest. If you're still having trouble, it would be helpful to know more about the specific error messages you're seeing. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@329609045289992192> kapa.ai is still learning and improving, please let us know how it did by reacting below