I am building a Laravel 7.x. application that will combine both standard authentication (user logs on via form) and API authentication through Sanctum (token based). I want to generate a sanctum API token during successful user authentication. To do that, I need to hook into the login flow.
Standard authentication was scaffolded to my application by running php artisan ui vue --auth.
When I inspect routes/web.php, I can see only Auth::routes(); which under the hood allegedly generates the classic routes I was used to in previous Laravel versions. Taken from the answer I linked, /login route definition that is generated looks like this:
$this->post('login', 'Auth\LoginController@login');
However, when I inspect my LoginController that was scaffolded, I can not see any of the methods that should be generated by Auth::routes(). There is nothing in there and it looks like everything is handled transparently to me as a developer:
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = RouteServiceProvider::HOME;
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
How do I hook into the login flow and add my own actions to it?