types

package
v0.0.0-...-65546df Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFund       = statuserr.Errorf("user not found").SetCode(1_400_000).SetStatus(status.BadRequest)
	ErrUserAlreadyExists = statuserr.Errorf("user already exists").SetCode(1_400_002).SetStatus(status.BadRequest)
	ErrPasswordMismatch  = statuserr.Errorf("password mismatch").SetCode(1_400_004).SetStatus(status.BadRequest)
	ErrEmailAlreadyUsed  = statuserr.Errorf("email already used by other").SetCode(1_400_016).SetStatus(status.BadRequest)

	ErrVerifyCodeRetryLater       = statuserr.Errorf("retry applying for verify code later").SetCode(1_400_032).SetStatus(status.BadRequest)
	ErrVerifyCodeInvalid          = statuserr.Errorf("invliad verify code").SetCode(1_400_033).SetStatus(status.BadRequest)
	ErrVerifyCodeUsageUnsupported = statuserr.Errorf("verify code usage unsupported").SetCode(1_400_036).SetStatus(status.BadRequest)

	ErrCredentialInvalid = statuserr.Errorf("invalid credential").SetCode(1_401_001).SetStatus(status.Unauthorized)
	ErrCredentialExpired = statuserr.Errorf("credential expired").SetCode(1_401_002).SetStatus(status.Unauthorized)
	ErrTokenNeedsRefresh = statuserr.Errorf("token need to refresh").SetCode(1_401_003).SetStatus(status.Unauthorized)
)

Functions

func CheckValidUsage

func CheckValidUsage(u Usage) error

Types

type CaptchaOption

type CaptchaOption struct {
	// email receiver
	To string `json:"to" binding:"email"`
	// verify code usage: 1-register 2-reset password
	Usage Usage `json:"usage" binding:"required,gte=1,lte=2"`
}

type EmailBody

type EmailBody struct {
	ContentType mail.ContentType `mapstructure:"contentType"`
	From        string           `mapstructure:"from"`
	To          []string         `mapstructure:"to"`
	CC          []string         `mapstructure:"cc"`
	Bcc         []string         `mapstructure:"bcc"`
	Subject     string           `mapstructure:"subject"`
	Body        string           `mapstructure:"body"`
}

EmailBody represents an email message body

type LoginOptions

type LoginOptions struct {
	// username or email
	Username string `json:"username" binding:"required"`
	// user password
	Password string `json:"password" binding:"required"`
	// remember user or not
	Remember bool `json:"remember"`
}

type RefreshTokenOptions

type RefreshTokenOptions struct {
	// access token
	AccessToken string `json:"accessToken" binding:"required"`
	// refresh token
	RefreshToken string `json:"refreshToken" binding:"required"`
}

type RegisterOptions

type RegisterOptions struct {
	// username must be alphanumeric
	Username string `json:"username" binding:"required,alphanum"`
	// user password
	Password string `json:"password" binding:"required"`
	// user email address
	Email string `json:"email" binding:"email"`
	// verification code from verify email
	Code string `json:"code" binding:"required,alphanum"`
}

type ResetOptions

type ResetOptions struct {
	// user email address
	Email string `json:"email" binding:"email"`
	// new password
	Password string `json:"password" binding:"required"`
	// verification code from verify email
	Code string `json:"code" binding:"required"`
}

type SearchUserOptions

type SearchUserOptions struct {
	Page   int    `form:"page" binding:"required,gt=0"`
	Size   int    `form:"size" binding:"required,gt=0"`
	Search string `form:"search"`
}

type TokenPayload

type TokenPayload struct {
	Username string `json:"username"`
	UserId   string `json:"userId"`
}

type TokenResult

type TokenResult struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken,omitempty"`
}

type UidOptions

type UidOptions struct {
	Uid string `form:"uid" uri:"uid" binding:"required"`
}

type Usage

type Usage int
const (
	UsageUnknown  Usage = 0
	UsageRegister Usage = 1
	UsageReset    Usage = 2
)

func (Usage) Name

func (u Usage) Name() string

func (Usage) String

func (u Usage) String() string

type UserInfo

type UserInfo struct {
	Uid       string `json:"uid"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	CreatedAt int64  `json:"created_at"`
}

func EntToUser

func EntToUser(user *ent.User) UserInfo

func EntsToUsers

func EntsToUsers(users []*ent.User) []UserInfo

type UserSearchResult

type UserSearchResult struct {
	Total int64      `json:"total"`
	List  []UserInfo `json:"list"`
}

Jump to

Keyboard shortcuts

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