#Authorizing User Model
13 messages · Page 1 of 1 (latest)
is there something wrong with the code?
thank you
how can i authenticate with a bearer token before a controller action is run?
By using auth middleware.
public function login(Request $request)
{
$validated = $request->validate([
'email' => ['required', 'email'],
'password' => ['required', 'min:8']
]);
if (Auth::attempt($validated)) {
$user = Auth::user();
$user->tokens()->delete();
$token = $user->createToken($validated['email'])->plainTextToken;
return ['token' => $token];
}
}
what about that!?
how does it look/feel ?!
I don’t really understand what you’re showing me? Why are you showing me a login function with username and password if you actually want to authenticate using a bearer token? 🤷♂️
maybe you don't understand, because you are a little dumb? login functions with username and password are closely working together with bearer tokens. 😉
That is wrong @thorny pasture and please watch your words
According to Laravel, auth bearer tokens are to be used to authenticate third party applications
Think you’re the dumb one. Have yourself a timeout if you’re going to be a tosser.