feat: align NewSzxcn admin experience

This commit is contained in:
zxyszx
2026-08-02 15:07:16 +08:00
parent 7c6b0838b5
commit 9b59629993
23 changed files with 583 additions and 828 deletions
@@ -88,6 +88,17 @@ func (a *App) handleApplyMailbox(w http.ResponseWriter, r *http.Request) {
respondError(w, http.StatusConflict, "该邮箱地址已被占用")
return
}
if user.Role != "admin" && user.Limits.MaxMailboxCount > 0 {
var ownedCount int
if err := a.db.QueryRowContext(r.Context(), `SELECT COUNT(*) FROM mailboxes WHERE user_id=? AND status='active'`, user.ID).Scan(&ownedCount); err != nil {
respondError(w, http.StatusInternalServerError, "failed to check mailbox quota")
return
}
if ownedCount >= user.Limits.MaxMailboxCount {
respondError(w, http.StatusForbidden, "邮箱数量已达上限")
return
}
}
var passwordHash string
if err := a.db.QueryRowContext(r.Context(), `SELECT password_hash FROM users WHERE id=? AND disabled=0`, user.ID).Scan(&passwordHash); err != nil {