【新增】输入管理员密码,登出指定账号
This commit is contained in:
@@ -108,7 +108,7 @@ public class AuthController {
|
|||||||
// 判断账号是否登录过
|
// 判断账号是否登录过
|
||||||
if (oAuth2AccessTokenDO.getUserInfo().get("username").equals(reqVO.getUsername())) {
|
if (oAuth2AccessTokenDO.getUserInfo().get("username").equals(reqVO.getUsername())) {
|
||||||
// 说明登录了,别的地方登录了,请重新登录
|
// 说明登录了,别的地方登录了,请重新登录
|
||||||
return CommonResult.error(900001, "该账号已经登录");
|
return CommonResult.error(900001, "该账号已经登录!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success(authService.login(reqVO));
|
return success(authService.login(reqVO));
|
||||||
@@ -125,7 +125,28 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
@PostMapping("/refreshLogout")
|
||||||
|
@PermitAll
|
||||||
|
@TenantIgnore
|
||||||
|
@Operation(summary = "使用管理员密码强制登出用户")
|
||||||
|
public CommonResult<String> refreshLoginout(@RequestBody LoginoutVo loginoutVo) {
|
||||||
|
// 先判断管理员密码
|
||||||
|
ConfigDO config = configService.getConfigByKey("system_username_logout");
|
||||||
|
if (!config.getValue().equals(loginoutVo.getLoginOutPassword())) {
|
||||||
|
return CommonResult.error(900002, "系统管理员密码错误!");
|
||||||
|
}
|
||||||
|
Set<String> oauth2_access_token_set = stringRedisTemplate.keys("oauth2_access_token:*");
|
||||||
|
for (String oauth2_access_token : oauth2_access_token_set) {
|
||||||
|
OAuth2AccessTokenDO oAuth2AccessTokenDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(oauth2_access_token), OAuth2AccessTokenDO.class);
|
||||||
|
// 判断账号是否登录过
|
||||||
|
if (oAuth2AccessTokenDO.getUserInfo().get("username").equals(loginoutVo.getUsername())) {
|
||||||
|
// 说明登录了,别的地方登录了,请重新登录
|
||||||
|
stringRedisTemplate.opsForValue().getAndDelete(oauth2_access_token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success("退出成功,请重新输入用户名密码登录!");
|
||||||
|
}
|
||||||
@PostMapping("/refresh-token")
|
@PostMapping("/refresh-token")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@Operation(summary = "刷新令牌")
|
@Operation(summary = "刷新令牌")
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
package pc.exam.pp.module.system.controller.admin.auth.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LoginoutVo {
|
||||||
|
|
||||||
|
private String loginOutPassword;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
}
|
Reference in New Issue
Block a user