首页 > 解决方案 > 从护照中的一台设备注销用户

问题描述

我有这种注销方法,用户可以使用两个设备(移动设备和网络)登录,但是注销时,它会撤销所有用户的令牌。我希望当用户从 web 注销时,可以使用移动应用程序,反之亦然。

 public function logout(Request $request)
    {
        try {
            if (Auth::check()) {
                $token = $request->user()->token();
                $token->revoke();
                return $this->success('You have successfully logged out.');
            }else{
                return $this->failure('Unauthorized.',401);
            }
        } catch (Exception $e) {
            return $this->failure('Unauthorized.',401);
        }
        return $this->failure('Unauthorized.',401);
    }

标签: laravellaravel-passport

解决方案


推荐阅读