laravel - 从护照中的一台设备注销用户
问题描述
我有这种注销方法,用户可以使用两个设备(移动设备和网络)登录,但是注销时,它会撤销所有用户的令牌。我希望当用户从 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);
}
解决方案
推荐阅读
- rs485 - RS-485 总线多传感器
- grails - GroovyCastException:无法将具有 A 类的对象 A 转换为 A 类
- apache - apache-tomcat-8.5.30 应用程序不工作
- javascript - 使用 Java 脚本在 Google 地图上的多个标记之间画线
- c# - 无法确定类型为“System.Data.SqlClient.SqlConnection”的连接的 DbProviderFactory 类型
- php - 验证波兰和外国手机号码
- angularjs - UI 显示为大空间
- java - vert.x 中 http 配置检索器中的 Cookie
- mongodb - 从单独的文件中获取 mongoDB 中用户的数据
- r - 合并两个有一个共同边的染色体盒数据类型