probable-pink
probable-pink6mo ago

auth error

Type '({ credential }: CredentialResponse) => Promise<void | AuthActionResponse>' is not assignable to type '(params: any) => Promise<AuthActionResponse>'. Type 'Promise<void | AuthActionResponse>' is not assignable to type 'Promise<AuthActionResponse>'. Type 'void | AuthActionResponse' is not assignable to type 'AuthActionResponse'. Type 'void' is not assignable to type 'AuthActionResponse'.ts(2322) auth.d.ts(54, 5): The expected type comes from property 'login' which is declared here on type 'AuthBindings' (property) login: (params: any) => Promise<AuthActionResponse>
2 Replies
kapa.ai
kapa.ai6mo ago
Hi @jakshire01. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing is a TypeScript error. It's saying that the login method in your authProvider is not returning a Promise that resolves to an AuthActionResponse for all code paths. In refine, the login method of the authProvider should always return a Promise that resolves to an AuthActionResponse. The AuthActionResponse is an object that should have a success property and optionally an error property if success is false. Here's an example of how the login method should be structured:
login: async ({ email, password }) => {
// Your authentication logic here...
// If authentication is successful:
return {
success: true,
};

// If authentication fails:
return {
success: false,
error: {
name: "Login Failed!",
message: "The email or password that you've entered doesn't match any account.",
},
};
}
login: async ({ email, password }) => {
// Your authentication logic here...
// If authentication is successful:
return {
success: true,
};

// If authentication fails:
return {
success: false,
error: {
name: "Login Failed!",
message: "The email or password that you've entered doesn't match any account.",
},
};
}
(Source: refine.dev docs (https://refine.dev/docs/api-reference/core/providers/auth-provider/#login)) Make sure that all code paths in your login method return a Promise that resolves to an AuthActionResponse. If there are any code paths that could potentially return void (for example, if you have an if statement without a corresponding else), you'll need to add code to handle those cases and return an AuthActionResponse. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@418995770205929473> kapa.ai is still learning and improving, please let us know how it did by reacting below