换设备重新绑定
This commit is contained in:
@@ -56,20 +56,19 @@ public class AuthService {
|
||||
stored = deviceId;
|
||||
log.info("[auth] first-login bind userId={} device={}", user.getId(), deviceId);
|
||||
} else if (!stored.equals(deviceId)) {
|
||||
if (isAdmin) {
|
||||
log.warn("[auth] device mismatch but admin bypass userId={} stored={} current={}",
|
||||
user.getId(), stored, deviceId);
|
||||
} else {
|
||||
log.warn("[auth] device mismatch reject userId={} stored={} current={}",
|
||||
user.getId(), stored, deviceId);
|
||||
throw new BusinessException("当前设备与首次登录设备不一致,请在原设备上登录");
|
||||
}
|
||||
// 设备指纹变化(换电脑/重装/清理注册表)会锁死账号,密码已验证通过,
|
||||
// 直接重新绑定到当前设备,避免账号被锁、数据因重建账号而丢失。
|
||||
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
||||
.eq(LoginUserEntity::getId, user.getId())
|
||||
.set(LoginUserEntity::getMachine, deviceId));
|
||||
log.warn("[auth] device rebound on login userId={} old={} new={}",
|
||||
user.getId(), stored, deviceId);
|
||||
} else {
|
||||
log.info("[auth] device match userId={} isAdmin={} device={}",
|
||||
user.getId(), isAdmin, deviceId);
|
||||
}
|
||||
|
||||
return buildResult(user, stored, isAdmin);
|
||||
return buildResult(user, deviceId, isAdmin);
|
||||
}
|
||||
|
||||
public LoginResultVo checkLogin(String token, String currentDeviceId) {
|
||||
|
||||
Reference in New Issue
Block a user