user

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ErrCodeEmailAlreadyExists = "email_exists"
View Source
const ErrCodeEmailEmpty = "email_empty"
View Source
const ErrCodeEmailSendFailed = "email_send_failed"
View Source
const ErrCodeEmailSendTooFrequent = "email_send_too_frequent"
View Source
const ErrCodeEmailTokenInvalid = "email_token_invalid"
View Source
const ErrCodeEmailTooLong = "email_too_long"
View Source
const ErrCodeFirstnameTooLong = "firstname_too_long"
View Source
const ErrCodeLastnameTooLong = "lastname_too_long"
View Source
const ErrCodePasswordEmpty = "password_empty"
View Source
const ErrCodePasswordTooLong = "password_too_long"
View Source
const ErrCodePasswordTooShort = "password_too_short"
View Source
const ErrCodeUserNotFound = "user_not_found"
View Source
const ErrCodeUsernameAlreadyExists = "username_exists"
View Source
const ErrCodeUsernameOrPasswordIncorrect = "username_or_password_incorrect"
View Source
const ErrCodeUsernameReserved = "username_reserved"
View Source
const ErrCodeUsernameTooLong = "username_too_long"
View Source
const ErrCodeUsernameTooShort = "username_too_short"

Variables

View Source
var ErrEmailAlreadyExists = srvcerror.New(
	ErrCodeEmailAlreadyExists,
	"epasts jau eksistē",
).SetHttpStatusCode(http.StatusConflict)
View Source
var ErrUserNotFound = srvcerror.New(
	ErrCodeUserNotFound,
	"lietotājs netika atrasts",
).SetHttpStatusCode(http.StatusNotFound)

Functions

func NewUserService

func NewUserService(pg *pgxpool.Pool, mailer mail.Mailer, emailCfg EmailFlowConfig) *userSrvc

Types

type CreateUserParams

type CreateUserParams struct {
	Username  string
	Email     string
	Firstname *string
	Lastname  *string
	Password  string
}

type EmailFlowConfig added in v1.1.0

type EmailFlowConfig struct {
	WebsiteBaseURL  string
	ResetTokenTTL   time.Duration
	VerifyTokenTTL  time.Duration
	PerUserCooldown time.Duration
}

type JWTClaims

type JWTClaims struct {
	Username  *string
	Firstname *string
	Lastname  *string
	Email     *string
	UUID      *string
	Scopes    []string
	Issuer    *string
	Subject   *string
	Audience  []string
	ExpiresAt *string
	IssuedAt  *string
	NotBefore *string
}

type User

type User struct {
	UUID          uuid.UUID
	Username      string
	Email         string
	Firstname     *string
	Lastname      *string
	EmailVerified bool
}

type UserService

type UserService interface {
	GetUserByUsername(ctx context.Context, username string) (User, srvcerror.E)
	GetUserByUUID(ctx context.Context, uuid uuid.UUID) (User, srvcerror.E)
	Login(ctx context.Context, username string, password string) (*User, srvcerror.E)
	CreateUser(ctx context.Context, user CreateUserParams) (*User, srvcerror.E)
	RequestPasswordReset(ctx context.Context, login string) srvcerror.E
	ConfirmPasswordReset(ctx context.Context, token string, newPassword string) srvcerror.E
	RequestEmailVerification(ctx context.Context, userUUID uuid.UUID) srvcerror.E
	ConfirmEmailVerification(ctx context.Context, token string) srvcerror.E
	PasswordChangedAt(ctx context.Context, userUUID uuid.UUID) (time.Time, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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