Add the operator console's user-administration pages over the existing
*user.Service (no new business logic).
- GET /_gm/users paginated account list
- GET /_gm/users/{id} account detail: profile, entitlement, sanctions
- POST /_gm/users/{id}/block apply permanent_block (reason required)
- POST /_gm/users/{id}/entitlement set the entitlement tier
- POST /_gm/users/{id}/soft-delete soft-delete the account (cascades)
The console depends on a UserAdmin interface (satisfied by *user.Service) so the
pages render in tests without a database. All writes flow through the CSRF
guard, carry the operator as the audit actor, and answer with a 303 redirect;
a generic message page handles not-found, validation, and failure notices.
Unblock is intentionally absent — the admin API exposes no remove-sanction
endpoint.
Tests: list/detail render, not-found, block (with actor/scope/reason
assertions), missing-reason 400, bad-CSRF 403, entitlement, soft-delete
redirect, and the service-unavailable path.
Docs: backend/docs/admin-console.md gains the page inventory.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package adminconsole
|
||||
|
||||
// UserRow is one line in the users list table.
|
||||
type UserRow struct {
|
||||
UserID string
|
||||
Email string
|
||||
UserName string
|
||||
DisplayName string
|
||||
Tier string
|
||||
Blocked bool
|
||||
Deleted bool
|
||||
CreatedAt string
|
||||
}
|
||||
|
||||
// UsersListData is the view model for the paginated users list.
|
||||
type UsersListData struct {
|
||||
Items []UserRow
|
||||
Page int
|
||||
PageSize int
|
||||
Total int
|
||||
HasPrev bool
|
||||
HasNext bool
|
||||
PrevPage int
|
||||
NextPage int
|
||||
}
|
||||
|
||||
// SanctionView is one active sanction shown on the user detail page.
|
||||
type SanctionView struct {
|
||||
SanctionCode string
|
||||
Scope string
|
||||
ReasonCode string
|
||||
AppliedAt string
|
||||
ExpiresAt string
|
||||
}
|
||||
|
||||
// UserDetailData is the view model for a single user's detail page,
|
||||
// combining the account aggregate with the form option lists.
|
||||
type UserDetailData struct {
|
||||
UserID string
|
||||
Email string
|
||||
UserName string
|
||||
DisplayName string
|
||||
PreferredLanguage string
|
||||
TimeZone string
|
||||
DeclaredCountry string
|
||||
Blocked bool
|
||||
Deleted bool
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
|
||||
Tier string
|
||||
IsPaid bool
|
||||
EntitlementSource string
|
||||
EntitlementReason string
|
||||
EntitlementEnds string
|
||||
|
||||
Sanctions []SanctionView
|
||||
|
||||
// Tiers lists the selectable entitlement tiers for the form.
|
||||
Tiers []string
|
||||
}
|
||||
Reference in New Issue
Block a user