12 Replies
Hi @Belvis. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Refine provides a way to customize the error message displayed when the
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:
In this example, the name
property will be the title of the notification, and the message
property will be the subtitle.
If you want to use a custom login page, you can use the useLogin
hook. Here's an example:
In this 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.
For more information, refer to the useLogin
documentation (https://refine.dev/docs/authentication/hooks/use-login/) and the AuthProvider documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login).
Sources:
- useLogin documentation (https://refine.dev/docs/authentication/hooks/use-login#usage)
- AuthProvider documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below
foreign-sapphireOP•12mo ago
i dont want to show notification, how to turn it off ? @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
In Refine, you can disable notifications by setting the
successNotification
and errorNotification
props to false
in the data hooks. This can be done for hooks like useUpdate
and useForm
. Here's an example:
Similarly, for useForm
:
This will prevent the success and error notifications from being displayed when the hook is called.
For more information, refer to the Notification Providers documentation (https://refine.dev/docs/guides-concepts/notifications#notification-providers).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below
foreign-sapphireOP•12mo ago
i dont want to show notification for useLogin, how to turn it off ? @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
To disable notifications for the
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:
In this example, when the login is unsuccessful (success: false
), no error object is returned, so no error notification will be displayed.
For more information, refer to the AuthProvider documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below
foreign-sapphireOP•12mo ago
@kapa.ai it doesn't work, I edited the error object but the notification didn't change, something else is controlling it not the authProvider @@
Let me check the knowledge base for you. One moment! :books:
----------------------
I apologize for the confusion. The
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
.
However, you can create a custom login page and handle the login process manually to avoid automatic notifications. Here's an example:
In this example, we're using the 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.
Please note that this is a workaround and might not be the best practice. It's always recommended to handle errors and notify users about them to improve the user experience.
For more information, refer to the useLogin documentation (https://refine.dev/docs/authentication/hooks/use-login) and the useNotify documentation (https://refine.dev/docs/api-reference/hooks/notification/useNotify).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below
ambitious-aqua•12mo ago
Hello @Belvis, auth hooks will show notification if error happens and if you have notification provider. Currently, you can't disable that.