user

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrID = errs.NewValidation().Add("id", "Invalid")

ErrID el id del documento es invalido

View Source
var ErrLogin = errs.NewValidation().Add("login", "invalid")

ErrLogin el login es invalido

View Source
var ErrPassword = errs.NewValidation().Add("password", "invalid")

ErrPassword el password es invalido

Functions

This section is empty.

Types

type DbUserIdFilter

type DbUserIdFilter struct {
	ID primitive.ObjectID `bson:"_id"`
}

type DbUserLoginFilter

type DbUserLoginFilter struct {
	Login string `bson:"login"`
}

type DbUserUpdateDocument

type DbUserUpdateDocument struct {
	Set DbUserUpdateDocumentBody `bson:"$set"`
}

type DbUserUpdateDocumentBody

type DbUserUpdateDocumentBody struct {
	Name        string    `bson:"name" validate:"required,min=1,max=100"`
	Password    string    `bson:"password" validate:"required"`
	Permissions []string  `bson:"permissions"`
	Enabled     bool      `bson:"enabled"`
	Updated     time.Time `bson:"updated"`
}

type User

type User struct {
	ID          primitive.ObjectID `bson:"_id"`
	Name        string             `bson:"name" validate:"required,min=1,max=100"`
	Login       string             `bson:"login" validate:"required,min=5,max=100"`
	Password    string             `bson:"password" validate:"required"`
	Permissions []string           `bson:"permissions"`
	Enabled     bool               `bson:"enabled"`
	Created     time.Time          `bson:"created"`
	Updated     time.Time          `bson:"updated"`
}

User data structure

func NewUser

func NewUser() *User

NewUser Nueva instancia de usuario

func (*User) SetPasswordText

func (e *User) SetPasswordText(pwd string) error

SetPasswordText Asigna la contraseña en modo texto, la encripta

type UserData

type UserData struct {
	Id          string   `json:"id"`
	Name        string   `json:"name"`
	Permissions []string `json:"permissions"`
	Login       string   `json:"login"`
	Enabled     bool     `json:"enabled"`
}

func NewUserData

func NewUserData(user *User) *UserData

func (UserData) IsEntity

func (UserData) IsEntity()

type UserRepository

type UserRepository interface {
	Insert(usr *User) (*User, error)
	Update(usr *User) (*User, error)
	FindAll() ([]*User, error)
	FindByID(userID string) (*User, error)
	FindByLogin(login string) (*User, error)
}

func NewUserRepository

func NewUserRepository(
	log log.LogRusEntry,
	collection db.Collection,
) UserRepository

type UserService

type UserService interface {
	ChangePassword(userID string, current string, newPassword string) error
	Disable(userID string) error
	Enable(userID string) error
	FindById(userID string) (*UserData, error)
	FindAllUsers() ([]*UserData, error)
	Grant(userID string, permissions []string) error
	Granted(userID string, permission string) bool
	Revoke(userID string, permissions []string) error
	New(login string, name string, password string) (result *UserData, err error)
	SignIn(login string, password string) (user *UserData, err error)
}

func NewUserService

func NewUserService(userRepository UserRepository) UserService

Jump to

Keyboard shortcuts

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