login method resolves the promise with success: false. You can resolve the promise with an error object that has name and message properties. Here's an example:name property will be the title of the notification, and the message property will be the subtitle.useLogin hook. Here's an example:mutate acquired from useLogin can accept any kind of object for values since login method from authProvider doesn't have a restriction on its parameters.useLogin documentation (https://refine.dev/docs/authentication/hooks/use-login/) and the AuthProvider documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login).successNotification and errorNotification props to false in the data hooks. This can be done for hooks like useUpdate and useForm. Here's an example:useForm:useLogin hook, you can customize the login method in your authProvider to not return an error object when the login is unsuccessful. Here's an example:success: false), no error object is returned, so no error notification will be displayed.useLogin hook in Refine automatically handles error notifications and it's not currently possible to disable these notifications directly from the hook or the authProvider.useLogin hook to manually handle the login process. If there's an error, we can handle it manually and decide whether to show a notification or not.loginloginloginsuccess: falsesuccess: falseuseLoginuseLoginuseLoginuseLoginuseLoginuseLoginmutateauthProviderauthProviderauthProvidersuccessNotificationerrorNotificationuseUpdateimport { AuthBindings } from "@refinedev/core";
const authProvider: AuthBindings = {
login: async ({ email, password }) => {
return {
success: false,
error: {
name: "Login Failed!",
message: "The email or password that you've entered doesn't match any account.",
},
};
},
}; import { useLogin } from "@refinedev/core";
import { Form } from "antd";
type LoginVariables = {
username: string;
password: string;
};
export const LoginPage = () => {
const { mutate: login } = useLogin<LoginVariables>();
const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
login({
username: event.currentTarget.username.value,
password: event.currentTarget.password.value,
});
};
return (
<Form
onFinish={onSubmit}
>
{/* ... */}
</Form>
);
}; import { useUpdate } from "@refinedev/core";
const { mutate } = useUpdate();
mutate({
// By setting it to `false`, you can disable the notification.
successNotification: false,
errorNotification: false,
});import { useForm } from "@refinedev/core";
useForm({
// By setting it to `false`, you can disable the notification.
successNotification: false,
errorNotification: false,
});import { AuthBindings } from "@refinedev/core";
const authProvider: AuthBindings = {
login: async ({ email, password }) => {
// ---
return {
success: false,
// Do not return an error object
};
},
// ---
}; import { useLogin, useNotify } from "@pankod/refine";
const LoginPage = () => {
const { mutate: login } = useLogin();
const notify = useNotify();
const handleLogin = async (values) => {
const { error } = await login(values);
if (error) {
// Handle error manually
// notify.error("Custom error message");
}
};
return (
<form onSubmit={handleLogin}>
{/* Your form fields */}
</form>
);
};