feat(cabana): add the My account page with subtitle and password change
- lagoon: 202610090001_backend_users_metadata adds WinterCMS's nullable jsonable backend_users.metadata column (TEXT); rollback drops only it - cabana.BackendUser.Metadata and Subtitle read metadata.subtitle leniently (NULL, blank, null, [], invalid JSON and non-strings read as empty) - GET /auth/me returns subtitle; PUT /account edits the signed-in admin's own names, email and subtitle, and the password with current_password; any other key is a 422 and nothing is written - email: required, valid, 6-255 chars, unique against other admins' email and login ignoring case (soft-deleted included); a unique-index race is 422 - a password change sets tokens_valid_after, revokes the presented token and gives a cookie session a fresh cookie - swag annotation, regenerated admin.json and schema.d.ts; route inventories, CSRF walk (27) and OpenAPI conformance learn the route - SPA: My account item in the user menu opens /account (AccountView), which saves through PUT /account and updates the top bar via setCurrentUser - backend::lang.myaccount strings (en, pl), rebuilt boardwalk dist - cabana and lagoon READMEs, users-and-permissions and admin-spa docs
This commit is contained in:
@@ -30,6 +30,9 @@ func (BackendUserRole) TableName() string { return "backend_user_roles" }
|
||||
// BackendUser is the Winter backend_users row. It is not a frontend user.
|
||||
// Nullable Winter columns are mapped so a copied row round-trips without a
|
||||
// schema transform. TokensValidAfter is the admin reset cutoff, not a Winter column.
|
||||
// Metadata is Winter's jsonable metadata column kept as raw text, so a copied
|
||||
// value that is not a JSON object (NULL, blank or []) still loads; read it
|
||||
// through Subtitle.
|
||||
type BackendUser struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
FirstName string `gorm:"column:first_name"`
|
||||
@@ -41,6 +44,7 @@ type BackendUser struct {
|
||||
PersistCode string `gorm:"column:persist_code"`
|
||||
ResetPasswordCode string `gorm:"column:reset_password_code"`
|
||||
Permissions string `gorm:"column:permissions"`
|
||||
Metadata *string `gorm:"column:metadata"`
|
||||
IsActivated bool `gorm:"column:is_activated"`
|
||||
IsSuperuser bool `gorm:"column:is_superuser"`
|
||||
RoleID *uint `gorm:"column:role_id"`
|
||||
@@ -55,6 +59,11 @@ type BackendUser struct {
|
||||
|
||||
func (BackendUser) TableName() string { return "backend_users" }
|
||||
|
||||
// Subtitle returns metadata.subtitle, the key WinterCMS's Journal author
|
||||
// component reads. NULL, blank, null, [], invalid JSON and a non-string value
|
||||
// all read as an empty subtitle.
|
||||
func (u BackendUser) Subtitle() string { return metadataString(u.Metadata, metadataSubtitle) }
|
||||
|
||||
// Option is a dropdown choice shared with later schema plans.
|
||||
type Option = pact.Option
|
||||
|
||||
|
||||
Reference in New Issue
Block a user