chore: change permission check

This commit is contained in:
Noah Hsu
2022-06-29 17:08:31 +08:00
parent bf950ee6e1
commit a09a1b814b
6 changed files with 52 additions and 16 deletions

View File

@ -21,6 +21,7 @@ type User struct {
Role int `json:"role"` // user's role
IgnoreHide bool `json:"can_hide"` // can see hide files
IgnorePassword bool `json:"ignore_password"` // can access without password
Aira2 bool `json:"aira_2"` // can add aria2 tasks
}
func (u User) IsGuest() bool {
@ -40,3 +41,7 @@ func (u User) ValidatePassword(password string) error {
}
return nil
}
func (u User) CanWrite() bool {
return u.IsAdmin() || !u.ReadOnly
}