[英]how I can pass the token to header not in body using jwt.auth middleware :laravel 5.6
[英]Laravel - How can i set the Auth::attempt to a user if i only have a JWT token with the email and the id
我有两个项目; 第一个只是一个 JWT 登录名,如果成功,它会重定向到另一个带有令牌的 Laravel 项目。 在另一个项目中,我验证了令牌,但该项目已经启动了很多代码,并且它使用方法Auth::user()->"retrieve data"
。
问题是我不知道如何使用Auth::attempt()
进行身份验证,只有 email 或 JWT,或者最好的方法是什么,如果我可以删除所有带有 Auth 的行: : 并实例化 cookies,获取有效负载并将Auth::attempt()
替换为 cookie 用户的一些 model。
谢谢,对不起,如果我试图解释这个问题不清楚。 如果我做错了什么,请告诉我; 我是这方面的初学者。
我不知道最好的方法是尝试Auth::attempt
/ Auth::user
还是退出它并用 cookie 中包含 JWT 的有效负载替换它。
假设您已经正确验证了用户,您可以使用Auth::login($user)
请参阅文档https://laravel.com/docs/9.x/authentication#authenticate-a-user-instance
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.