services

package
v0.0.0-...-9e6572e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClient

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

AuthClient is the client that handles authentication requests

func NewAuthClient

func NewAuthClient(cfg *config.Config, orm *ent.Client) *AuthClient

NewAuthClient creates a new authentication client

func (*AuthClient) CheckPassword

func (c *AuthClient) CheckPassword(password, hash string) error

CheckPassword проверьте, соответствует ли данный пароль заданному хэшу

func (*AuthClient) DeletePasswordTokens

func (c *AuthClient) DeletePasswordTokens(ctx echo.Context, userID int) error

DeletePasswordTokens удаляет все токены пароля в базе данных, относящиеся к данному пользователю. Это должно быть вызвано после успешного сброса пароля.

func (*AuthClient) GenerateEmailVerificationToken

func (c *AuthClient) GenerateEmailVerificationToken(email string) (string, error)

GenerateEmailVerificationToken генерирует токен подтверждения электронной почты для данного адреса электронной почты с помощью JWT, который устанавливается на срок действия в зависимости от продолжительности, сохраненной в конфигурации

func (*AuthClient) GeneratePasswordResetToken

func (c *AuthClient) GeneratePasswordResetToken(ctx echo.Context, userID int) (string, *ent.PasswordToken, error)

GeneratePasswordResetToken генерирует токен сброса пароля для данного пользователя. В целях безопасности сам токен не хранится в базе данных, а скорее хэш токена, точно указывающий, как обрабатываются пароли. Этот метод возвращает оба сгенерированный токен, а также объект token, который содержит только хэш.

func (*AuthClient) GetAuthenticatedUser

func (c *AuthClient) GetAuthenticatedUser(ctx echo.Context) (*ent.User, error)

GetAuthenticatedUser возвращает аутентифицированного пользователя, если пользователь вошел в систему

func (*AuthClient) GetAuthenticatedUserID

func (c *AuthClient) GetAuthenticatedUserID(ctx echo.Context) (int, error)

GetAuthenticatedUserID возвращает идентификатор аутентифицированного пользователя, если пользователь вошел в систему

func (*AuthClient) GetValidPasswordToken

func (c *AuthClient) GetValidPasswordToken(ctx echo.Context, userID, tokenID int, token string) (*ent.PasswordToken, error)

GetValidPasswordToken возвращает действительный объект токена пароля с не истекшим сроком действия для данного пользователя, идентификатора токена и токена-метки. Поскольку фактический токен не хранится в базе данных в целях безопасности, если найден соответствующий объект токена пароля, хэш предоставленного токена сравнивается с хэшем, хранящимся в базе данных, для проверки.

func (*AuthClient) HashPassword

func (c *AuthClient) HashPassword(password string) (string, error)

HashPassword возвращает хэш заданного пароля

func (*AuthClient) Login

func (c *AuthClient) Login(ctx echo.Context, userID int) (string, error)

Login logs in a user of a given ID

func (*AuthClient) Logout

func (c *AuthClient) Logout(ctx echo.Context) error

Logout выводит запрашивающего пользователя из системы

func (*AuthClient) RandomToken

func (c *AuthClient) RandomToken(length int) (string, error)

RandomToken генерирует случайную строку токена заданной длины

func (*AuthClient) ValidateEmailVerificationToken

func (c *AuthClient) ValidateEmailVerificationToken(token string) (string, error)

ValidateEmailVerificationToken проверяет токен подтверждения электронной почты и возвращает связанный адрес электронной почты, если токен действителен и срок его действия не истек

type CacheClient

type CacheClient struct {
	// Client stores the client to the underlying cache service
	Client *redis.Client
	// contains filtered or unexported fields
}

CacheClient is the client that allows you to interact with the cache

func NewCacheClient

func NewCacheClient(cfg *config.Config) (*CacheClient, error)

NewCacheClient creates a new cache client

func (*CacheClient) Close

func (c *CacheClient) Close() error

Close closes the connection to the cache

func (*CacheClient) Flush

func (c *CacheClient) Flush() *cacheFlush

Flush creates a cache flush operation

func (*CacheClient) Get

func (c *CacheClient) Get() *cacheGet

Get creates a cache get operation

func (*CacheClient) Set

func (c *CacheClient) Set() *cacheSet

Set creates a cache set operation

type Container

type Container struct {
	// Validator stores a validator
	Validator *Validator

	// Web хранит веб-фреймворк
	Web *echo.Echo

	// Config stores the application configuration
	Config *config.Config

	// Cache contains the cache client
	Cache *CacheClient

	// Database stores the connection to the database
	Database *sql.DB

	// ORM stores a client to the ORM
	ORM *ent.Client

	// Auth stores an authentication client
	Auth *AuthClient

	// Tasks stores the task client
	Tasks *TaskClient
}

Container содержит все службы, используемые приложением, и предоставляет простой способ обработки зависимостей инъекция, в том числе в рамках тестов

func NewContainer

func NewContainer() *Container

NewContainer creates and initializes a new Container

func (*Container) Shutdown

func (c *Container) Shutdown() error

Shutdown shuts the Container down and disconnects all connections

type InvalidPasswordTokenError

type InvalidPasswordTokenError struct{}

InvalidPasswordTokenError is an error returned when an invalid token is provided

func (InvalidPasswordTokenError) Error

Error implements the error interface.

type JwtCustomClaims

type JwtCustomClaims struct {
	UserId int `json:"user_id"`
	jwt.RegisteredClaims
}

type NotAuthenticatedError

type NotAuthenticatedError struct{}

NotAuthenticatedError is an error returned when a user is not authenticated

func (NotAuthenticatedError) Error

func (e NotAuthenticatedError) Error() string

Error implements the error interface.

type TaskClient

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

TaskClient is that client that allows you to queue or schedule task execution

func NewTaskClient

func NewTaskClient(cfg *config.Config) *TaskClient

NewTaskClient creates a new task client

func (*TaskClient) Close

func (t *TaskClient) Close() error

Close closes the connection to the task service

func (*TaskClient) New

func (t *TaskClient) New(typ string) *task

New starts a task creation operation

func (*TaskClient) StartScheduler

func (t *TaskClient) StartScheduler() error

StartScheduler starts the scheduler service which adds scheduled tasks to the queue This must be running in order to queue tasks set for periodic execution

type Validator

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

Validator provides validation mainly validating structs within the web context

func NewValidator

func NewValidator() *Validator

NewValidator creats a new Validator

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Validate validates a struct

Jump to

Keyboard shortcuts

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