package application

import "github.com/go-arrower/arrower/contexts/auth/internal/application"

Index

Variables

var ErrBlockUserFailed = errors.New("block user failed")
var ErrLoginUserFailed = errors.New("login user failed")
var ErrNewUserFailed = errors.New("new user failed")
var ErrRegisterUserFailed = errors.New("register user failed")
var ErrSendNewUserVerificationEmailFailed = errors.New("send new user verification email failed")
var ErrShowUserFailed = errors.New("show user failed")
var ErrUnblockUserFailed = errors.New("unblock user failed")
var ErrVerifyUserFailed = errors.New("verify user failed")

Functions

func NewBlockUserRequestHandler

func NewBlockUserRequestHandler(repo domain.Repository) app.Request[BlockUserRequest, BlockUserResponse]

func NewListUsersQueryHandler

func NewListUsersQueryHandler(repo domain.Repository) app.Query[ListUsersQuery, ListUsersResponse]

func NewLoginUserRequestHandler

func NewLoginUserRequestHandler(
	logger alog.Logger,
	repo domain.Repository,
	queue jobs.Enqueuer,
	authenticator *domain.AuthenticationService,
) app.Request[LoginUserRequest, LoginUserResponse]

func NewNewUserCommandHandler

func NewNewUserCommandHandler(
	repo domain.Repository,
	registrator *domain.RegistrationService,
) app.Command[NewUserCommand]

func NewRegisterUserRequestHandler

func NewRegisterUserRequestHandler(
	logger alog.Logger,
	repo domain.Repository,
	registrator *domain.RegistrationService,
	queue jobs.Enqueuer,
) app.Request[RegisterUserRequest, RegisterUserResponse]

func NewSendNewUserVerificationEmailJobHandler

func NewSendNewUserVerificationEmailJobHandler(
	logger alog.Logger,
	repo domain.Repository,
) app.Job[NewUserVerificationEmail]

func NewShowUserQueryHandler

func NewShowUserQueryHandler(
	repo domain.Repository,
) app.Query[ShowUserQuery, ShowUserResponse]

func NewUnblockUserRequestHandler

func NewUnblockUserRequestHandler(repo domain.Repository) app.Request[UnblockUserRequest, UnblockUserResponse]

func NewVerifyUserCommandHandler

func NewVerifyUserCommandHandler(repo domain.Repository) app.Command[VerifyUserCommand]

Types

type BlockUserRequest

type BlockUserRequest struct {
	UserID domain.ID `validate:"required"`
}

type BlockUserResponse

type BlockUserResponse struct {
	Blocked domain.BoolFlag
	UserID  domain.ID
}

type ListUsersQuery

type ListUsersQuery struct {
	Query  string
	Filter domain.Filter
}

type ListUsersResponse

type ListUsersResponse struct {
	Users    []domain.User
	Filtered uint
	Total    uint
}

type LoginUserRequest

type LoginUserRequest struct {
	LoginEmail string `form:"login"    validate:"max=1024,required,email"`
	Password   string `form:"password" validate:"max=1024,min=8"`

	IsNewDevice bool
	UserAgent   string `validate:"max=2048"`
	IP          string `validate:"ip"`
	SessionKey  string
}

type LoginUserResponse

type LoginUserResponse struct {
	User domain.User
}

type NewUserCommand

type NewUserCommand struct {
	Email       string `form:"email"       validate:"max=1024,required,email"`
	FirstName   string `form:"firstName"   validate:"max=1024"`
	LastName    string `form:"lastName"    validate:"max=1024"`
	DisplayName string `form:"displayName" validate:"max=1024"`
	Superuser   bool   `form:"superuser"   validate:"boolean"`
}

type NewUserVerificationEmail

type NewUserVerificationEmail struct {
	UserID     domain.ID
	OccurredAt time.Time
	IP         domain.ResolvedIP
	Device     domain.Device
}

type RegisterUserRequest

type RegisterUserRequest struct {
	RegisterEmail          string `form:"login"                 validate:"max=1024,required,email"`
	Password               string `form:"password"              validate:"max=1024,min=8"`
	PasswordConfirmation   string `form:"password_confirmation" validate:"max=1024,eqfield=Password"`
	AcceptedTermsOfService bool   `form:"tos"                   validate:"required"`

	UserAgent  string `validate:"max=2048"`
	IP         string `validate:"ip"`
	SessionKey string
}

type RegisterUserResponse

type RegisterUserResponse struct {
	User domain.Descriptor
}

type SendConfirmationNewDeviceLoggedIn

type SendConfirmationNewDeviceLoggedIn struct {
	UserID     domain.ID
	OccurredAt time.Time
	IP         domain.ResolvedIP
	Device     domain.Device
}

type ShowUserQuery

type ShowUserQuery struct {
	UserID domain.ID
}

type ShowUserResponse

type ShowUserResponse struct {
	User domain.User
}

type UnblockUserRequest

type UnblockUserRequest struct {
	UserID domain.ID `validate:"required"`
}

type UnblockUserResponse

type UnblockUserResponse struct {
	Blocked domain.BoolFlag
	UserID  domain.ID
}

type UserApplication

type UserApplication struct {
	RegisterUser app.Request[RegisterUserRequest, RegisterUserResponse]
	LoginUser    app.Request[LoginUserRequest, LoginUserResponse]
	ListUsers    app.Query[ListUsersQuery, ListUsersResponse]
	ShowUser     app.Query[ShowUserQuery, ShowUserResponse]
	NewUser      app.Command[NewUserCommand]
	VerifyUser   app.Command[VerifyUserCommand]
	BlockUser    app.Request[BlockUserRequest, BlockUserResponse]     // todo refactor to a command
	UnblockUser  app.Request[UnblockUserRequest, UnblockUserResponse] // todo refactor to a command
}

type VerifyUserCommand

type VerifyUserCommand struct {
	UserID domain.ID `validate:"required"`
	Token  uuid.UUID `validate:"required"`
}

Source Files

app.go block-user.usecase.go list-users.usecase.go login-user.usecase.go new-user.usecase.go register-user.usecase.go send-new-user-verification-email.usecase.go show-user.usecase.go unblock-user.usecase.go verify-user.usecase.go

Version
v0.0.0-20250311203644-ab26c1152cb4 (latest)
Published
Mar 11, 2025
Platform
linux/amd64
Imports
12 packages
Last checked
1 week ago

Tools for package owners.