Laravel Sanctum SPA身份验证注销不起作用 [英] Laravel sanctum SPA authentication logout is not working
本文介绍了Laravel Sanctum SPA身份验证注销不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Vue项目中使用了laravel sanctum SPA身份验证.一切都很好,但即使注销也可以正常工作
I am using laravel sanctum SPA authentication in my Vue project.Everything is working well but even after logout
Auth::logout()
我仍然能够从中间件内部的api路由获取数据
I am still able to get datas from api route inside middleware
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
我应该无法在注销后获取数据,它应该显示401未经身份验证,但事实并非如此.如何解决这个问题.我在这里呆了3天.我也遵循laravel文档和其他教程,但是每个注销都和我一样.
I should not be able to get datas after logout.It should show 401 unauthenticated but its not the case. How to solve this problem.I have been stuck here for 3 days.I followed laravel documentation and other tutorial as well but every one logged out same like I did.
推荐答案
请使用 Auth :: guard('web')-> logout();
代替 Auth ::注销()
.调查 SPA退出问题
这篇关于Laravel Sanctum SPA身份验证注销不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文