account

package
v0.0.0-...-fc927da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreatorsGroupName    string = "creators"
	AdminsGroupName      string = "admin"
	SuperAdminsGroupName string = "super-admin"
	PlayersGroupName     string = "players"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ACL

type ACL struct {
	Owner  ACLFlag
	Group  ACLFlag
	Others ACLFlag
}
var DefaultPermissions *ACL = NewACL()

func NewACL

func NewACL() *ACL

type ACLFlag

type ACLFlag uint8
const (
	ACLNone      ACLFlag = 0
	ACLRead      ACLFlag = 1
	ACLReadWrite ACLFlag = 2
)

type Group

type Group struct {
	model.Base
	Name   string `gorm:"unique,uniqueIndex" json:"name"`
	Admins []User `gorm:"many2many:group_admins," json:"-"`
}

type User

type User struct {
	model.Base
	Email          string `gorm:"unique;uniqueIndex"`
	Name           string
	Groups         []Group `gorm:"many2many:user_groups;"`
	AdminOfGroups  []Group `gorm:"many2many:group_admins;"`
	Domain         string  //Likely just to be part of the email
	LastIdProvider string
}

func CheckAuth

func CheckAuth(r *http.Request) (*User, error)

func (*User) CanReadObject

func (user *User) CanReadObject(userObject *UserObject) bool

func (*User) CanWriteObject

func (user *User) CanWriteObject(userObject *UserObject) bool

func (*User) GroupIDs

func (user *User) GroupIDs() []uuid.UUID

func (*User) InjectReadAuth

func (user *User) InjectReadAuth(DB *gorm.DB) *gorm.DB

type UserObject

type UserObject struct {
	model.Base
	OwnerID     uuid.UUID `json:"ownerId"`
	Owner       User      `json:"-"` //Gorm should use the field above to create an association by foreign key.
	GroupID     uuid.UUID `json:"-"`
	Group       Group     `json:"group"`
	Permissions ACL       `gorm:"embedded;embeddedPrefix:acl_"`
}

func (*UserObject) BeforeCreate

func (userObject *UserObject) BeforeCreate(db *gorm.DB) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL