Answer the question
In order to leave comments, you need to log in
Laravel - how to authorize a user from under api in the web?
To work with applications via api, I installed Laravel passport
/config/auth.php:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
$user = User::create([
'name' => $request->has('name') ? $request->name : '',
'first_name' => $request->has('first_name') ?? $request->first_name,
'last_name' => $request->has('last_name') ?? $request->first_name,
'email' => $request->email,
'password' => bcrypt($request->password),
]);
Auth::login($user);
Auth::guard('web')->login($user);
Answer the question
In order to leave comments, you need to log in
And why topsy-turvy from the "usual" scenario?
Usually they register, log in, and then you can issue tokens and anything to work with api.
In the API, why should it be logged in, it is not designed for this at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question