feat: extend enterprise gateway policies billing protocols and operations

This commit is contained in:
wlx committed 2026-10-13 19:08:50 +08:00
1 parent 1528b71882
commit af43947b5d
67 files changed
+1822 -69

No files matched your search

@@ -34,6 +34,7 @@ public class AuthService {
private final ObjectMapper objectMapper;
private final int sessionTtlHours;
private final SecretCipher secretCipher;
@Autowired private TotpService totp;
/** Kept for isolated unit tests that do not exercise encrypted invitation display. */
public AuthService(
@@ -119,6 +120,9 @@ public class AuthService {
}
public AuthResult login(String accountInput, String password, RequestMeta meta) {
return login(accountInput,password,null,meta);
}
public AuthResult login(String accountInput,String password,String otp,RequestMeta meta) {
UserRow user = findUserByAccount(normalizeAccount(accountInput));
if (user == null || !passwordHasher.matches(password, user.passwordHash())) {
throw new ApiException("INVALID_CREDENTIALS", "账号或密码错误", 401);
@@ -126,11 +130,16 @@ public class AuthService {
if (!"active".equals(user.status())) {
throw new ApiException("ACCOUNT_DISABLED", "账号已停用", 403);
}
if(totp!=null) totp.verifyLogin(user.id(),otp);
OffsetDateTime loginAt = now();
jdbc.update("UPDATE users SET last_login_at = ?, updated_at = ? WHERE id = ?", loginAt, loginAt, user.id());
audit("user.logged_in", user.id(), meta, Map.of());
return new AuthResult(createSession(user.id(), meta), toView(user, loginAt));
}
public void verifyPassword(UUID userId,String password) {
String hash=jdbc.queryForObject("SELECT password_hash FROM users WHERE id=? AND status='active'",String.class,userId);
if(password==null||!passwordHasher.matches(password,hash)) throw new ApiException("INVALID_CREDENTIALS","当前密码错误",401);
}
@Transactional
public AuthResult register(