登录黑名单清除失效问题
This commit is contained in:
@@ -18,4 +18,10 @@ public interface GatewayFeignClient {
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
Response<Void> logout(@RequestParam("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 清除用户黑名单,允许该用户重新登录(登录时会自动调用)。
|
||||
*/
|
||||
@PostMapping("/clear-blacklist")
|
||||
Response<Void> clearBlacklist(@RequestParam("userId") Long userId);
|
||||
}
|
||||
|
||||
@@ -366,6 +366,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// 同步写入 Redis,重启后仍然可用
|
||||
long jwtExpiration = tokenGenerateUtils.getJwtExpiration();
|
||||
redisUtil.setLoginToken(account.getId(), token2, jwtExpiration);
|
||||
// 清除黑名单,允许用户重新登录(仅当黑名单功能开启时)
|
||||
try {
|
||||
gatewayFeignClient.clearBlacklist(account.getId());
|
||||
} catch (Exception e) {
|
||||
log.warn("登录时清除黑名单失败,userId={}, error={}", account.getId(), e.getMessage());
|
||||
}
|
||||
return token2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user