role

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkedToUser = errors.New("role is linked to user")

Functions

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) common.CrudAPI

func TransformBitmaskToActions

func TransformBitmaskToActions(bitmask int64, roleType string) []string

Types

type AggregationResult

type AggregationResult struct {
	Data       []Role `bson:"data" json:"data"`
	TotalCount int64  `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type CreateRequest

type CreateRequest struct {
	EditRequest
	Name string `json:"name" binding:"required,max=255"`
}

type EditRequest

type EditRequest struct {
	Description string              `json:"description" binding:"max=255"`
	DefaultView string              `json:"defaultview"`
	Permissions map[string][]string `json:"permissions"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy string `form:"sort_by" binding:"oneoforempty=name"`
}

type Permission

type Permission struct {
	ID          string   `bson:"_id" json:"_id"`
	Name        string   `bson:"name" json:"name"`
	Description string   `bson:"description" json:"description"`
	Type        string   `bson:"type" json:"type"`
	Bitmask     int64    `bson:"bitmask" json:"-"`
	Actions     []string `bson:"actions" json:"actions"`
}

type Role

type Role struct {
	ID          string `bson:"_id" json:"_id"`
	Name        string `bson:"name" json:"name"`
	Description string `bson:"description" json:"description"`
	DefaultView *struct {
		ID    string `bson:"_id" json:"_id"`
		Title string `bson:"title" json:"title"`
	} `bson:"defaultview" json:"defaultview"`
	Permissions []Permission `bson:"permissions" json:"permissions"`
}

type Store

type Store interface {
	Find(ListRequest) (*AggregationResult, error)
	GetOneBy(string) (*Role, error)
	Insert(CreateRequest) (*Role, error)
	Update(string, EditRequest) (*Role, error)
	Delete(string) (bool, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient) Store

type Validator

type Validator interface {
	ValidateCreateRequest(ctx context.Context, sl validator.StructLevel)
	ValidateEditRequest(ctx context.Context, sl validator.StructLevel)
}

func NewValidator

func NewValidator(dbClient mongo.DbClient) Validator

Jump to

Keyboard shortcuts

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