complete reset async billing and upstream key rotation
This commit is contained in:
1 parent
b54b6a8ac4
commit
a80896e3c7
19 files changed
+531
-50
No files matched your search
@@ -256,6 +256,23 @@ public class AuthService {
|
||||
return toView(findUserById(user.id()), null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void resetPassword(String accountInput, String newPassword, RequestMeta meta) {
|
||||
String account = normalizeAccount(accountInput);
|
||||
UserRow user = findUserByAccount(account);
|
||||
if (user == null || !"active".equals(user.status())) {
|
||||
throw new ApiException("ACCOUNT_NOT_FOUND", "账号不存在或已停用", 404);
|
||||
}
|
||||
if (newPassword == null || newPassword.isBlank() || newPassword.length() > 256
|
||||
|| (!"super_admin".equals(user.role()) && newPassword.length() < 8)) {
|
||||
throw new ApiException("WEAK_PASSWORD", "普通用户新密码长度为 8 至 256 位", 400);
|
||||
}
|
||||
OffsetDateTime changedAt = now();
|
||||
jdbc.update("UPDATE users SET password_hash=?, updated_at=? WHERE id=?", passwordHasher.hash(newPassword), changedAt, user.id());
|
||||
jdbc.update("UPDATE auth_sessions SET revoked_at=? WHERE user_id=? AND revoked_at IS NULL", changedAt, user.id());
|
||||
audit("user.password_reset", user.id(), meta, Map.of());
|
||||
}
|
||||
|
||||
private boolean isAdminRole(String role) {
|
||||
return "admin".equals(role) || "super_admin".equals(role);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user