feat(auth): center-scoped single admin + GET /admin-email + cli
Triage channels in Guilds need to deliver every message to a single
"observer" admin user across the whole Center deployment (regardless of
on-duty / mention). This adds the data + auth surface for that.
## Schema
`users.isAdmin TINYINT DEFAULT 0` (synchronize:true auto-applies; cli
`user set-admin` enforces at-most-one in a transaction).
## CLI (subject `user`)
- `set-admin --email <e>` — clears every other admin row first, then
marks the target. Returns `{admin: {email, userId}}`
- `clear-admin` — unsets all (returns `{cleared: N}`)
- `show-admin` — prints `{admin: {email, userId}}` or `{admin: null}`
## HTTP
`GET /auth/admin-email` (NOT @Public — requires a guild-node api key
via the existing CenterApiKeyGuard). Returns:
- `{email: "...", userId: "..."}` if an admin exists
- `null` (literal JSON) if no admin
Guild backends cache the result (1 day TTL per spec; with cli refresh
override on guild side).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,19 @@ export class User {
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
refreshTokenHash!: string | null;
|
||||
|
||||
/**
|
||||
* Center-scoped admin flag. At most one user should have this set at a
|
||||
* time; the cli `user set-admin` enforces single-admin by clearing all
|
||||
* other admins before promoting the target user. Guild backends learn
|
||||
* the current admin via `GET /admin-email`.
|
||||
*
|
||||
* Use: triage channels deliver every message to the admin as a silent
|
||||
* observer (wake=false) regardless of on-duty / mention status, so a
|
||||
* single human can audit all triage traffic.
|
||||
*/
|
||||
@Column({ type: 'tinyint', default: 0, name: 'isAdmin' })
|
||||
isAdmin!: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user