![](/img/trans.png)
[英]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.