登录黑名单清除失效问题

This commit is contained in:
litianxiang
2026-05-29 16:02:03 +08:00
parent 3d9a6aa9e9
commit 931eef6f53
2 changed files with 12 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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;
}