code-8
code-8

Reputation: 58632

How to authenticate user base on JWT API - Laravel 5.8?

I'm using PHP 7.2 on Laravel 5.8.

I current use Auth provider that came with Laravel to log my users in.

It currently check if the email, and password match in the database configured.

I did this

$dbAuth = Auth::attempt(array(
    'email' => $email,
    'password' => $password
));

if ($dbAuth) {

    return Redirect::to('/dashboard')->with('success', 'You have been successfully logged in.');

} else {
    return Redirect::to('/')->with('error', 'Username/Password Wrong')->with('email', $email)->withErrors($validator);
} 

I can't do that anymore, I have to talk to call an API that return a token.


Just to clarify :

My main goal is to call JWT API, and logged my user in if I got the 200 response.

How do log my users in now?

Upvotes: 0

Views: 139

Answers (1)

Ahmed Gamal
Ahmed Gamal

Reputation: 96

I would recommend you use this package for JWT auth, it has a good documentation as well.

https://github.com/tymondesigns/jwt-auth

Upvotes: 1

Related Questions