alist/internal/model/user.go

25 lines
578 B
Go
Raw Normal View History

2022-06-16 08:06:10 +00:00
package model
const (
GENERAL = iota
GUEST // only one exists
ADMIN
)
type User struct {
2022-06-25 12:38:02 +00:00
ID uint `json:"id" gorm:"primaryKey"` // unique key
Name string `json:"name" gorm:"unique"` // username
Password string `json:"password"` // password
BasePath string `json:"base_path"` // base path
ReadOnly bool `json:"read_only"` // allow upload
Role int `json:"role"` // user's role
2022-06-16 08:06:10 +00:00
}
func (u User) IsGuest() bool {
return u.Role == GUEST
}
func (u User) IsAdmin() bool {
return u.Role == ADMIN
}