Made it easier to edit avatars
This commit is contained in:
@ -56,7 +56,7 @@ type User struct {
|
||||
UserAgent string `json:"agent" private:"true"`
|
||||
Balance int `json:"balance" private:"true"`
|
||||
Image Image `json:"image"`
|
||||
Avatar UserAvatar `json:"avatar"`
|
||||
Avatar UserAvatar `json:"avatar" editable:"true"`
|
||||
Cover UserCover `json:"cover"`
|
||||
Accounts UserAccounts `json:"accounts" private:"true"`
|
||||
Browser UserBrowser `json:"browser" private:"true"`
|
||||
|
@ -96,10 +96,10 @@ func (user *User) Edit(ctx aero.Context, key string, value reflect.Value, newVal
|
||||
user.BirthDay = newBirthDay
|
||||
return true, nil
|
||||
|
||||
case "ProExpires":
|
||||
user := GetUserFromContext(ctx)
|
||||
case "ProExpires", "Avatar.Extension", "Avatar.LastModified":
|
||||
editor := GetUserFromContext(ctx)
|
||||
|
||||
if user == nil || user.Role != "admin" {
|
||||
if editor == nil || editor.Role != "admin" {
|
||||
return true, errors.New("Not authorized to edit")
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,8 @@ var avatarOutputs = []imageserver.Output{
|
||||
|
||||
// UserAvatar ...
|
||||
type UserAvatar struct {
|
||||
Extension string `json:"extension"`
|
||||
Source string `json:"source"`
|
||||
LastModified int64 `json:"lastModified"`
|
||||
Extension string `json:"extension" editable:"true"`
|
||||
LastModified int64 `json:"lastModified" editable:"true"`
|
||||
}
|
||||
|
||||
// SetImageBytes accepts a byte buffer that represents an image file and updates the avatar.
|
||||
|
Reference in New Issue
Block a user