useSanctumAuth
Composable provides 2 computed properties and 3 methods:
user
- currently authenticated user (basically the same as useSanctumUser)isAuthenticated
- a boolean flag indicating whether the user is authenticated or notlogin
- method for logging in the userlogout
- method for logging out the userrefreshIdentity
- method for manually re-fetching current authenticated user data
To authenticate a user you should pass the credentials payload as an argument to the login
method. The payload should contain all fields required by your Laravel Sanctum backend.
If the login operation was successful, the user
property will be updated with the current user information returned by the Laravel API.
By default, methods will use the following Laravel endpoints:
/login
to authenticate the user/logout
to log out the user/api/user
to get the current user information/sanctum/csrf-cookie
to get theCSRF
token cookie
To change the default endpoints, please check the Configuration section.