Learn how to manage sessions, events, and different authentication options
Providers
and Events
, developers can implement or override specific aspects of the authentication flow, tailoring the user experience to meet the unique needs of their applications.
create
method to create a user session utilizing the data.token
returned from your backend, and return a status indicating whether the session creation was successful or not.
authenticate
method validates the user’s credentials, and the reset
method handles password reset requests.
authenticate
: This method attempts to log in the user using the provided loginId and password. If successful, it returns status: ‘logged-in’. If authentication fails, it returns status: ‘fail’ with a reason such as “Please enter a valid password.”reset
: This method handles the reset of user passwords. In this example, it redirects the user to a specific URL where they can manage password recovery.onFinish
event is triggered when the authentication flow is successfully completed. This event allows you to define actions that should be taken once the user is authenticated, such as redirecting the user to a specific page.
onAccountNotFound
to use your own registration flowsonAccountNotFound
event is triggered when the provided account details do not match any existing accounts. This event allows you to handle scenarios where a user needs to be registered or redirected to a registration page.
onClose
event is triggered when the authentication flow is closed, either by user action or automatically. This event allows developers to define what should happen when the authentication flow is interrupted or completed without a successful login.
onError
event is triggered when an error occurs during the authentication flow. This event allows developers to handle errors gracefully, such as by logging them or displaying error messages to the user.