I am currently using Laravel Sanctum for my Laravel Project with Vue SPA. I just wanted to ask, do I have to create my own Controllers to handle Login and Register or just use the Laravel default controllers installed when I run php artisan ui vue --auth. I followed some tutorials applying these both scenarios but I can't seem to decide which is a better approach.
Asked
Active
Viewed 1,043 times
1 Answers
2
This is quite subjective and is really personal preference.
Taking a look at the Laravel Sanctum docs:
...you should make a POST request to the typical Laravel /login route. This /login route may be provided by the laravel/jetstream authentication scaffolding package.
So if you're happy with the login/register functionality provided by the defaults Laravel stubbed out with the --auth
option then use them.
If you prefer to customise the logic and write your own implementation then this is fine too.
As far as Sanctum is concerned, it doesn't look like it cares how this is done. When using it with an SPA, once you're authenticated with Laravel, I imagine Sanctum uses a cookie to authenticate the session from there on out.

James
- 15,754
- 12
- 73
- 91