app/auth/group.go

31 lines
586 B
Go
Raw Permalink Normal View History

2021-12-16 04:11:33 +00:00
package auth
import (
"strings"
"time"
"gorm.io/gorm"
)
//Group enum of user permission groups
type Group struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
// Name starting with '*' is reserved and starting with '_' is internal
Name string `gorm:"unique;not null"`
DisplayName string
Description string
Users []*User `gorm:"many2many:user_groups;"`
}
func (grp *Group) BeforeSave(tx *gorm.DB) (err error) {
// set displayname
if grp.DisplayName == "" {
grp.DisplayName = strings.TrimPrefix(grp.Name, "*")
}
return
}