feat(cabana): add backend user avatars to My account and the top bar
- cabana.BackendUser is an attach.Owner (MorphName Backend\Models\User,
cabana.BackendUserMorphType) with one public attachOne avatar
(cabana.BackendUserAvatarField), as WinterCMS stores it
- POST /account/avatar stores one file_data image (jpg, jpeg, png, gif or
webp, image guard, at most cabana.AvatarMaxBytes = 2 MiB, under a
server-generated name) and replaces the previous avatar: old rows are
deleted in the transaction, their blobs after the commit
- DELETE /account/avatar removes the avatar and is idempotent
- GET /auth/me and the account routes return avatar {url, thumb_url}
(250x250 crop); cabana.BackendUserAvatar lets plugins read it
- swag annotations, regenerated admin.json and schema.d.ts; route
inventories, CSRF walk (29) and OpenAPI conformance learn both routes
- SPA: avatar upload and remove on My account, avatar image in the user
menu trigger and header; backend::lang.myaccount avatar strings
- rebuilt boardwalk dist; cabana README, users-and-permissions and
admin-spa docs
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/bouncer"
|
||||
"git.golem15.com/golem15/summercms/modules/lagoon/attach"
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -59,6 +60,25 @@ type BackendUser struct {
|
||||
|
||||
func (BackendUser) TableName() string { return "backend_users" }
|
||||
|
||||
const (
|
||||
// BackendUserMorphType is the system_files attachment_type of a backend
|
||||
// user's files: WinterCMS's class string, so avatar rows copied from
|
||||
// WinterCMS match as they are.
|
||||
BackendUserMorphType = "Backend\\Models\\User"
|
||||
// BackendUserAvatarField is the attachOne relation (system_files.field)
|
||||
// of a backend user's avatar.
|
||||
BackendUserAvatarField = "avatar"
|
||||
)
|
||||
|
||||
// MorphName implements attach.Owner with WinterCMS's class string.
|
||||
func (BackendUser) MorphName() string { return BackendUserMorphType }
|
||||
|
||||
// AttachRelations implements attach.HasRelations: one public attachOne
|
||||
// avatar, as WinterCMS's Backend\Models\User declares it.
|
||||
func (BackendUser) AttachRelations() []attach.Relation {
|
||||
return []attach.Relation{{Name: BackendUserAvatarField, Public: true}}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user