JWT中的注销不起作用,我使用流明5.8

问题描述 投票:0回答:1

我安装了JWT并登录,因此它可以工作并生成令牌,当我注销邮递员时,它返回200ok,但又一次又返回200ok,并且不生成无效令牌。

php laravel jwt lumen
1个回答
0
投票
public function login(User $user) { $this->validate($this->request, [ 'email' => 'required|email', 'password' => 'required' ]); // Find the user by email $user = User::where('email', $this->request->input('email'))->first(); if (!$user) { return response()->json([ 'error' => 'Email does not exist.' ], 400); } // Verify the password and generate the token if (Hash::check($this->request->input('password'), $user->password)) { return response()->json([ 'token' => $this->jwt($user) ], 200); } // Bad Request response return response()->json([ 'error' => 'Email or password is wrong.' ], 400); } public function logout(Request $request) { JWTAuth::invalidate(JWTAuth::parseToken());
}
© www.soinside.com 2019 - 2024. All rights reserved.