user

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist         = errors.New("user doesn't exist")
	ErrInvalidID        = errors.New("user id is invalid")
	ErrInvalidEmail     = errors.New("user email is invalid")
	ErrConflict         = errors.New("user already exist")
	ErrInvalidDetails   = errors.New("invalid user details (name|email)")
	ErrMissingName      = errors.New("user name is missing")
	ErrEmptyKey         = errors.New("empty key")
	ErrKeyAlreadyExists = errors.New("key already exist")
	ErrKeyDoesNotExists = errors.New("key does not exist")
	ErrMissingEmail     = errors.New("user email is missing")
	ErrInvalidUUID      = errors.New("invalid syntax of uuid")
	ErrDisabled         = errors.New("user is disabled")
)

Functions

This section is empty.

Types

type AccessPair added in v0.7.5

type AccessPair struct {
	User User
	On   string
	Can  []string
}

type Filter

type Filter struct {
	Limit int32
	Page  int32

	Keyword string
	OrgID   string
	GroupID string
	State   State
}

type PolicyService added in v0.7.19

type PolicyService interface {
	List(ctx context.Context, f policy.Filter) ([]policy.Policy, error)
}

type RelationService

type RelationService interface {
	Create(ctx context.Context, rel relation.Relation) (relation.Relation, error)
	BatchCheckPermission(ctx context.Context, relations []relation.Relation) ([]relation.CheckPair, error)
	Delete(ctx context.Context, rel relation.Relation) error
	LookupSubjects(ctx context.Context, rel relation.Relation) ([]string, error)
	LookupResources(ctx context.Context, rel relation.Relation) ([]string, error)
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (User, error)
	GetByEmail(ctx context.Context, email string) (User, error)
	GetByIDs(ctx context.Context, userIds []string) ([]User, error)
	GetByName(ctx context.Context, name string) (User, error)
	Create(ctx context.Context, user User) (User, error)
	List(ctx context.Context, flt Filter) ([]User, error)
	UpdateByID(ctx context.Context, toUpdate User) (User, error)
	UpdateByName(ctx context.Context, toUpdate User) (User, error)
	UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
	Delete(ctx context.Context, id string) error
	SetState(ctx context.Context, id string, state State) error
}

type RoleService added in v0.8.0

type RoleService interface {
	List(ctx context.Context, f role.Filter) ([]role.Role, error)
}

type Service

type Service struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewService

func NewService(repository Repository, relationRepo RelationService,
	policyService PolicyService, roleService RoleService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, user User) (User, error)

func (Service) Delete

func (s Service) Delete(ctx context.Context, id string) error

Delete by user uuid don't call this directly, use cascade deleter

func (Service) Disable

func (s Service) Disable(ctx context.Context, id string) error

func (Service) Enable

func (s Service) Enable(ctx context.Context, id string) error

func (Service) GetByEmail

func (s Service) GetByEmail(ctx context.Context, email string) (User, error)

func (Service) GetByID

func (s Service) GetByID(ctx context.Context, id string) (User, error)

GetByID email or slug

func (Service) GetByIDs

func (s Service) GetByIDs(ctx context.Context, userIDs []string) ([]User, error)

func (Service) IsSudo

func (s Service) IsSudo(ctx context.Context, id string, permissionName string) (bool, error)

IsSudo checks platform permissions. Platform permissions are: - superuser - check

func (Service) IsSudos added in v0.7.6

func (s Service) IsSudos(ctx context.Context, ids []string, permissionName string) ([]relation.Relation, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) ([]User, error)

func (Service) ListByGroup

func (s Service) ListByGroup(ctx context.Context, groupID string, roleFilter string) ([]User, error)

func (Service) ListByOrg

func (s Service) ListByOrg(ctx context.Context, orgID string, roleFilter string) ([]User, error)

func (Service) Sudo

func (s Service) Sudo(ctx context.Context, id string, relationName string) error

Sudo add platform permissions to user

func (Service) UnSudo added in v0.14.0

func (s Service) UnSudo(ctx context.Context, id string) error

UnSudo remove platform permissions to user only remove the 'member' relation if it exists

func (Service) Update

func (s Service) Update(ctx context.Context, toUpdate User) (User, error)

Update by user uuid, email or slug

func (Service) UpdateByEmail

func (s Service) UpdateByEmail(ctx context.Context, toUpdate User) (User, error)

type State

type State string
const (
	Enabled  State = "enabled"
	Disabled State = "disabled"
)

func (State) String

func (s State) String() string

type User

type User struct {
	ID        string
	Name      string
	Email     string
	State     State
	Avatar    string
	Title     string
	Metadata  metadata.Metadata
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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