This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
summer-utils/tables/user/perm.go
2023-04-16 11:56:17 +01:00

40 lines
755 B
Go

package user
import (
"code.mrmelon54.com/melon/summer/pkg/claims"
"code.mrmelon54.com/melon/summer/pkg/utils"
)
type Perm struct {
Id uint64 `json:"id" xorm:"pk autoincr"`
Key string `json:"key"`
Name string `json:"name"`
Desc string `json:"desc"`
Visible *bool `json:"visible"`
Enabled *bool `json:"enabled"`
IsPerm *bool `json:"isPerm"`
IsScope *bool `json:"isScope"`
}
func (p Perm) GetId() uint64 {
return p.Id
}
func (p Perm) SetEnabled(v bool) Perm {
p.Enabled = utils.PBool(v)
return p
}
func (p Perm) ClearForNew() Perm {
p.Id = 0
return p
}
func CheckSpecificPerms(storage *claims.PermStorage, v []string) []bool {
z := make([]bool, len(v))
for i := range v {
z[i] = storage.Has(v[i])
}
return z
}