user

package
v0.0.0-...-2db6053 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreateInpNil    = errors.New("user: create input is nil")
	ErrWrongConfirmPwd = errors.New("user: confirm password does not match")
)
View Source
var (
	ErrInvalidCred      = errors.New("invalid email or password")
	ErrAccountNotActive = errors.New("account is not active")
	ErrAccountLocked    = errors.New("account is locked, please try after sometime")
	ErrUnexpected       = errors.New("unexpected error has happened")
)
View Source
var (
	ErrExpiredToken = errors.New("expired token")
	ErrInvalidToken = errors.New("invalid token")
)

Functions

func Create

func Create(ctx context.Context, inp *CreateInput) (int64, error)

Create user record in DB

will return created userID on success

func CtxWithUser

func CtxWithUser(ctx context.Context, u *AuthUser) context.Context

func EmailResetPWD

func EmailResetPWD(email string)

EmailResetPWD link to user to reset password

func RemoveSession

func RemoveSession(sID uint)

RemoveSession entry from DB

func UpdatePWD

func UpdatePWD(token, email, pwd, confirmPWD string) error

UpdatePWD in database

func VerifyEmailAddress

func VerifyEmailAddress(ctx context.Context, token string) error

VerifyEmailAddress by a token

Types

type AuthUser

type AuthUser = model.AuthUser

func CtxUser

func CtxUser(ctx context.Context) *AuthUser

func NewSession

func NewSession(ctx context.Context, email, pwd string) (*AuthUser, error)

NewSession for user.

Authenticated

type CreateInput

type CreateInput struct {
	Email      string `validate:"email"`
	Phone      string
	Pwd        string `validate:"required"`
	ConfirmPwd string `validate:"required"`
	FirstName  string `validate:"required"`
	MiddleName string
	LastName   string
	RoleID     uint8 `validate:"required"`
}

Jump to

Keyboard shortcuts

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