user

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)
	GetUsernames(ctx context.Context, uuids []uuid.UUID) ([]string, 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