I have two projects; the first is just a JWT login that redirects, if successful, to another Laravel project with the token. In the other project, Ivalidatede the token, but that project is already with a lot of code started, and it works with the methods Auth::user()->"retrieve data"
.
The problem is that I don't know how to authenticate with the Auth::attempt()
, with only the email or the JWT, or what is the best way to do it, if I can delete all the lines with the Auth:: and instance the cookies, get the payload and replace the Auth::attempt()
with some model for the cookie user.
Thanks, and sorry if my attempt to explain the issue is unclear. And if I'm doing something wrong, please let me know; I'm a beginner at this.
I don't know if the best way to do this is to try the Auth::attempt
/ Auth::user
or quit that and replace it with the payload that has the JWT in the cookie.
CodePudding user response:
Assuming you've correctly validated the user, you can login with Auth::login($user)
See the docs https://laravel.com/docs/9.x/authentication#authenticate-a-user-instance