fix(鉴权): 单设备开关关闭时登录清除登出吊销标记
开关关掉后登录不再写 users.machine,而登出吊销借 machine 写 revoked@ 标记, 没人覆盖就永久留存——此后每次登录都先成功、再被 assertNotRevoked 判成 401「登录已过期,请重新登录」(2026-10-24 现网 admin 被锁死即此)。 登录成功即视为新会话,遇吊销标记时清空(仍不写设备号)。
This commit is contained in:
@@ -122,6 +122,14 @@ public class AuthService {
|
||||
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
||||
.eq(LoginUserEntity::getId, user.getId())
|
||||
.set(LoginUserEntity::getMachine, deviceId));
|
||||
} else if (DeviceSessionPolicy.isRevoked(user.getMachine())) {
|
||||
// 开关关掉后登录不再写 machine,登出留下的吊销标记就没人清:此后每次登录都会先成功、
|
||||
// 再被 requireUser 的 assertNotRevoked 判成「登录已过期」,账号永久锁死。
|
||||
// 登录成功即视为新会话,清空标记(空=未绑定,放行语义);仍不写设备号。
|
||||
log.warn("[auth] 登录清除登出吊销标记 userId={} username={}", user.getId(), user.getUsername());
|
||||
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
||||
.eq(LoginUserEntity::getId, user.getId())
|
||||
.set(LoginUserEntity::getMachine, ""));
|
||||
}
|
||||
log.info("[auth] login userId={} isAdmin={} device={}", user.getId(), isAdmin, deviceId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user