mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-03 20:21:40 +00:00
feat: add role field to user
This commit is contained in:
@ -19,6 +19,7 @@ type User struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
PasswordHash string `json:"-"`
|
||||
OpenID string `json:"openId"`
|
||||
Role Role `json:"role"`
|
||||
UserSettingList []*UserSetting `json:"userSettingList"`
|
||||
}
|
||||
|
||||
@ -28,15 +29,16 @@ type UserCreate struct {
|
||||
Password string `json:"password"`
|
||||
PasswordHash string `json:"-"`
|
||||
OpenID string `json:"-"`
|
||||
Role Role `json:"-"`
|
||||
}
|
||||
|
||||
func (create UserCreate) Validate() error {
|
||||
if !common.ValidateEmail(create.Email) {
|
||||
return fmt.Errorf("invalid email format")
|
||||
}
|
||||
if len(create.Email) < 3 {
|
||||
return fmt.Errorf("email is too short, minimum length is 6")
|
||||
}
|
||||
if !common.ValidateEmail(create.Email) {
|
||||
return fmt.Errorf("invalid email format")
|
||||
}
|
||||
if len(create.Password) < 3 {
|
||||
return fmt.Errorf("password is too short, minimum length is 6")
|
||||
}
|
||||
@ -69,6 +71,7 @@ type UserFind struct {
|
||||
Email *string `json:"email"`
|
||||
DisplayName *string `json:"displayName"`
|
||||
OpenID *string `json:"openId"`
|
||||
Role *Role `json:"-"`
|
||||
}
|
||||
|
||||
type UserDelete struct {
|
||||
|
Reference in New Issue
Block a user