diff --git a/api/user.go b/api/user.go index b2390a4f7..cb1e1ccd0 100644 --- a/api/user.go +++ b/api/user.go @@ -56,7 +56,6 @@ type UserCreate struct { Email string `json:"email"` Nickname string `json:"nickname"` Password string `json:"password"` - AvatarURL string `json:"avatarUrl"` PasswordHash string OpenID string } @@ -111,7 +110,12 @@ func (patch UserPatch) Validate() error { if patch.Nickname != nil && len(*patch.Nickname) > 64 { return fmt.Errorf("nickname is too long, maximum length is 64") } - if patch.Email != nil { + if patch.AvatarURL != nil { + if len(*patch.AvatarURL) > 2<<20 { + return fmt.Errorf("avatar is too large, maximum is 2MB") + } + } + if patch.Email != nil && *patch.Email != "" { if len(*patch.Email) > 256 { return fmt.Errorf("email is too long, maximum length is 256") } diff --git a/store/user.go b/store/user.go index 903782954..fdddbe506 100644 --- a/store/user.go +++ b/store/user.go @@ -182,10 +182,9 @@ func createUser(ctx context.Context, tx *sql.Tx, create *api.UserCreate) (*userR email, nickname, password_hash, - open_id, - avatar_url + open_id ) - VALUES (?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?) RETURNING id, username, role, email, nickname, password_hash, open_id, avatar_url, created_ts, updated_ts, row_status ` var userRaw userRaw @@ -196,7 +195,6 @@ func createUser(ctx context.Context, tx *sql.Tx, create *api.UserCreate) (*userR create.Nickname, create.PasswordHash, create.OpenID, - create.AvatarURL, ).Scan( &userRaw.ID, &userRaw.Username, diff --git a/web/src/components/Sidebar.tsx b/web/src/components/Sidebar.tsx index 746531c9f..000503aba 100644 --- a/web/src/components/Sidebar.tsx +++ b/web/src/components/Sidebar.tsx @@ -32,20 +32,32 @@ const Sidebar = () => {