user

package
v0.0.0-...-90cfb48 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PASSWORD_MIN_LENGTH = 8

	ERROR_PASSWORD_MIN_LENGTH = "provide password with min length %d"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminUsersResponse

type AdminUsersResponse struct {
	ID         string  `json:"id" db:"id"`
	Firstname  string  `json:"firstname" db:"firstname"`
	Lastname   string  `json:"lastname" db:"lastname"`
	Patronymic string  `json:"patronymic" db:"patronymic"`
	RoleId     int     `json:"role_id" db:"role_id"`
	Email      string  `json:"email" db:"email"`
	LastLogin  *string `json:"last_login" db:"last_login"`
}

type ChangePasswordRequest

type ChangePasswordRequest struct {
	OldPassword string `json:"old_password"`
	NewPassword string `json:"new_password"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Firstname  string  `json:"firstname"`
	Lastname   string  `json:"lastname"`
	Patronymic *string `json:"patronymic"`
	Email      string  `json:"email"`
	Password   string  `json:"password"`
}

type CreateUserResponse

type CreateUserResponse struct {
	UserId string `json:"id" db:"id"`
	RoleId int    `json:"role_id" db:"role_id"`
}

type EmailAndPasswordRequest

type EmailAndPasswordRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type EmailAndPasswordResponse

type EmailAndPasswordResponse struct {
	Password   string  `json:"password" db:"password"`
	ID         string  `json:"id" db:"id"`
	Firstname  string  `json:"firstname" db:"firstname"`
	Lastname   string  `json:"lastname" db:"lastname"`
	Patronymic *string `json:"patronymic" db:"patronymic"`
	RoleId     int     `json:"role_id" db:"role_id"`
}

type UpdateAllFieldsRequest

type UpdateAllFieldsRequest struct {
	Firstname  *string `json:"firstname"`
	Lastname   *string `json:"lastname"`
	Patronymic *string `json:"patronymic"`
	Email      *string `json:"email" db:"email"`
	RoleId     *int    `json:"role_id" db:"role_id"`
}

type UserClient

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

func (*UserClient) AllUsers

func (u *UserClient) AllUsers() ([]AdminUsersResponse, error)

func (*UserClient) ChangePassword

func (u *UserClient) ChangePassword(userId string, req ChangePasswordRequest) error

func (*UserClient) CreateUser

func (u *UserClient) CreateUser(cur CreateUserRequest) (*CreateUserResponse, error)

func (*UserClient) Delete

func (u *UserClient) Delete(userId string) (bool, error)

func (*UserClient) DeleteUsers

func (u *UserClient) DeleteUsers(ids []string) error

func (*UserClient) GetByEmailAndPassword

func (u *UserClient) GetByEmailAndPassword(req EmailAndPasswordRequest) (*EmailAndPasswordResponse, error)

func (*UserClient) GetWithID

func (u *UserClient) GetWithID(userId string) (*AdminUsersResponse, error)

func (*UserClient) GetWithoutID

func (u *UserClient) GetWithoutID(userId string) (*UserWithoutID, error)

func (*UserClient) Update

func (u *UserClient) Update(userId string, req UserUpdateRequest) (bool, error)

func (*UserClient) UpdateAllFields

func (u *UserClient) UpdateAllFields(userId string, req UpdateAllFieldsRequest) error

func (*UserClient) UpdateLastLogin

func (u *UserClient) UpdateLastLogin(userId string) error

type UserController

type UserController interface {
	CreateUser(cur CreateUserRequest) (*CreateUserResponse, error)
	GetByEmailAndPassword(req EmailAndPasswordRequest) (*EmailAndPasswordResponse, error)
	UpdateLastLogin(userId string) error
	GetWithoutID(userId string) (*UserWithoutID, error)
	Update(userId string, req UserUpdateRequest) (bool, error)
	Delete(userId string) (bool, error)
	ChangePassword(userId string, req ChangePasswordRequest) error
	AllUsers() ([]AdminUsersResponse, error)
	GetWithID(userId string) (*AdminUsersResponse, error)
	UpdateAllFields(userId string, req UpdateAllFieldsRequest) error
	DeleteUsers(ids []string) error
}

func NewUserClient

func NewUserClient(db *sqlx.DB) UserController

type UserUpdateRequest

type UserUpdateRequest struct {
	Firstname  *string `json:"firstname"`
	Lastname   *string `json:"lastname"`
	Patronymic *string `json:"patronymic"`
}

type UserWithoutID

type UserWithoutID struct {
	Firstname  string  `json:"firstname" db:"firstname"`
	Lastname   string  `json:"lastname" db:"lastname"`
	Patronymic *string `json:"patronymic" db:"patronymic"`
	RoleId     int     `json:"role_id" db:"role_id"`
	Email      string  `json:"email" db:"email"`
}

Jump to

Keyboard shortcuts

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