mirror of
https://github.com/AlistGo/alist.git
synced 2025-05-21 22:56:30 +08:00
feat: add user model
This commit is contained in:
24
internal/model/user.go
Normal file
24
internal/model/user.go
Normal file
@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
GENERAL = iota
|
||||
GUEST // only one exists
|
||||
ADMIN
|
||||
)
|
||||
|
||||
type User struct {
|
||||
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
|
||||
AllowUpload bool `json:"allow_upload"` // allow upload
|
||||
Role int `json:"role"` // user's role
|
||||
}
|
||||
|
||||
func (u User) IsGuest() bool {
|
||||
return u.Role == GUEST
|
||||
}
|
||||
|
||||
func (u User) IsAdmin() bool {
|
||||
return u.Role == ADMIN
|
||||
}
|
Reference in New Issue
Block a user