users

package
v4.1.13 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceGlobals

func ReplaceGlobals(repository Repository) func()

ReplaceGlobals affect a new repository to the global repository singleton

Types

type PostgresRepository

type PostgresRepository struct {
	// contains filtered or unexported fields
}

PostgresRepository is a repository containing the users data based on a PSQL database and implementing the repository interface

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(userWithPass security.UserWithPassword) (int64, error)

Create creates a new User in the repository

func (*PostgresRepository) Delete

func (r *PostgresRepository) Delete(id int64) error

Delete deletes an User in the repository

func (*PostgresRepository) Get

Get search and returns an User from the repository by its id

func (*PostgresRepository) GetAll

func (r *PostgresRepository) GetAll() (map[int64]security.User, error)

GetAll returns all users in the repository

func (*PostgresRepository) GetUsersOfGroup

func (r *PostgresRepository) GetUsersOfGroup(groupID int64) (map[int64]UserOfGroup, error)

GetUsersOfGroup returns all users of a Group in the repository

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(userWithPass security.User) error

Update updates an User in the repository

func (*PostgresRepository) UpdatePassword

func (r *PostgresRepository) UpdatePassword(userWithPass security.UserWithPassword) error

UpdatePassword updates an User password in the repository

type Repository

type Repository interface {
	Get(id int64) (security.User, bool, error)
	Create(user security.UserWithPassword) (int64, error)
	Update(user security.User) error
	Delete(id int64) error
	GetAll() (map[int64]security.User, error)
	GetUsersOfGroup(groupID int64) (map[int64]UserOfGroup, error)
}

Repository is a storage interface which can be implemented by multiple backend (in-memory map, sql database, in-memory cache, file system, ...) It allows standard CRUD operation on facts

func NewPostgresRepository

func NewPostgresRepository(dbClient *sqlx.DB) Repository

NewPostgresRepository returns a new instance of PostgresRulesRepository

func R

func R() Repository

R is used to access the global repository singleton

type UserOfGroup

type UserOfGroup struct {
	security.User
	RoleInGroup int64 `json:"groupRole" db:"role"`
}

UserOfGroup user in a group

Jump to

Keyboard shortcuts

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