models

package
v0.0.0-...-6f9a9ad Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidAction

func IsValidAction(action ActionType) bool

IsValidAction returns whether a given action is valid

Types

type ActionType

type ActionType string

ActionType action type

const (
	// ActionTypeRead read
	ActionTypeRead ActionType = "read"
	// ActionTypeWrite write
	ActionTypeWrite ActionType = "write"
	// ActionTypeUpdate update
	ActionTypeUpdate ActionType = "update"
	// ActionTypeDelete delete
	ActionTypeDelete ActionType = "delete"
	// ActionTypeAll all
	ActionTypeAll ActionType = "*"
)

type Permission

type Permission struct {
	// Resource resource to be accesible on the permission
	Resource ResourceType `json:"resource" bson:"resource"`
	// Action action to be done or performed on the resource
	Actions []ActionType `json:"actions" bson:"actions"`
}

Permission represents a permission related to a role

type ResourceType

type ResourceType string

ResourceType resource type

const (
	// ResourceTypeModule module
	ResourceTypeModule ResourceType = "module"
	// ResourceTypeUser user
	ResourceTypeUser ResourceType = "user"
)

type Role

type Role struct {
	// Name is the name of the role
	Name string `json:"roleName" bson:"roleName"`
	// Permissions the list of permissions linked to the role
	Permissions []Permission `json:"permissions" bson:"permissions"`
}

Role represents a role where permissions are defined

type User

type User struct {
	UserID       string    `json:"userID" bson:"_id"`
	PhoneNumber  string    `json:"phoneNumber" bson:"phoneNumber"`
	Name         string    `json:"name" bson:"name"`
	Email        string    `json:"email" bson:"email"`
	Password     string    `json:"password,omitempty" bson:"password"`
	RoleName     string    `json:"roleName" bson:"roleName"`
	CreationDate time.Time `json:"creationDate" bson:"creationDate"`
	UpdateDate   time.Time `json:"updateDate" bson:"updateDate"`
}

User user represents a user on the platform

Jump to

Keyboard shortcuts

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