feat: per-organization limits set by platform admins
Admins set default limits for monitors (all types), status pages and regions per monitor, whether an organization's own checker regions count towards the region limit, and how many organizations an account may own, and override them per organization or account. Defaults are not copied: changing one applies at once to everyone without an override. 0 means unlimited; self-hosted defaults are unlimited, the cloud allows three organizations per account. Creations count under a per-organization advisory lock, so concurrent requests cannot overshoot. A lowered limit keeps everything that exists: monitors already beyond the region limit stay editable but may not grow. Organizations see their usage in their settings and GET /org/limits; the admin panel lists organizations with owner, usage and limits next to their suspend and delete actions. Empty numeric form fields marked data-nullable are sent as null. Refs #111 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
90e74d091a
commit
e4ce619fbe
26 files changed
+2386
-82
No files matched your search
@@ -24,7 +24,7 @@ func (q *Queries) AnyUserExists(ctx context.Context) (bool, error) {
|
||||
|
||||
const createUser = `-- name: CreateUser :one
|
||||
INSERT INTO users (email, display_name, password_hash, locale) VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason
|
||||
RETURNING id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason, limit_orgs
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
@@ -55,6 +55,7 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e
|
||||
&i.Locale,
|
||||
&i.IsAdmin,
|
||||
&i.DisabledReason,
|
||||
&i.LimitOrgs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -95,7 +96,7 @@ func (q *Queries) EnableTOTP(ctx context.Context, arg EnableTOTPParams) error {
|
||||
}
|
||||
|
||||
const getUser = `-- name: GetUser :one
|
||||
SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason FROM users WHERE id = $1
|
||||
SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason, limit_orgs FROM users WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error) {
|
||||
@@ -114,12 +115,13 @@ func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error) {
|
||||
&i.Locale,
|
||||
&i.IsAdmin,
|
||||
&i.DisabledReason,
|
||||
&i.LimitOrgs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByEmail = `-- name: GetUserByEmail :one
|
||||
SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason FROM users WHERE email = $1
|
||||
SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason, limit_orgs FROM users WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
|
||||
@@ -138,6 +140,7 @@ func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error
|
||||
&i.Locale,
|
||||
&i.IsAdmin,
|
||||
&i.DisabledReason,
|
||||
&i.LimitOrgs,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user