model

package
v0.0.0-...-cf98a52 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordIsEmpty  = errors.New("password: is empty")
	ErrPasswordNotValid = errors.New("password: is not valid")
	ErrPasswordShort    = errors.New("password: is too short, must be at least 8 characters long")
	ErrPasswordLong     = errors.New("password: is too long, must be at most 64 characters long")
)
View Source
var ErrOTPNotValid = errors.New("otp: is not valid")

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ID       int64          `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	Avatar   string         `json:"avatar,omitempty" yaml:"avatar,omitempty" required:"true"`
	Email    string         `json:"email,omitempty" yaml:"email,omitempty" required:"true" format:"email"`
	Username string         `json:"username,omitempty" yaml:"username,omitempty" required:"true"`
	Salt     string         `json:"_" yaml:"-" hidden:"true"`
	Password Password       `json:"-" yaml:"-" hidden:"true"`
	OTP      OTP            `json:"-" yaml:"-" hidden:"true"`
	IsActive bool           `json:"isActive,omitempty" yaml:"isActive,omitempty" required:"false"`
	Roles    []string       `json:"roles,omitempty" yaml:"roles,omitempty" required:"true"`
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
	Created  time.Time      `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated  time.Time      `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
}

func (Admin) GetID

func (a Admin) GetID() int64

func (Admin) OTPKey

func (a Admin) OTPKey(issuer string) (string, error)

func (Admin) ValidateOTP

func (a Admin) ValidateOTP(password string) error

func (Admin) ValidatePassword

func (a Admin) ValidatePassword(password string) error

func (Admin) WithRandomSalt

func (a Admin) WithRandomSalt() Admin

type OTP

type OTP [otpSize]byte

func MustNewOTP

func MustNewOTP() OTP

func NewOTP

func NewOTP() (otp OTP, err error)

func (OTP) Compare

func (otp OTP) Compare(other OTP) int

func (OTP) IsZero

func (otp OTP) IsZero() bool

func (OTP) String

func (otp OTP) String() string

func (OTP) Validate

func (otp OTP) Validate(password string) error

type Password

type Password []byte

func NewPassword

func NewPassword(password string) (Password, error)

func (Password) IsZero

func (p Password) IsZero() bool

func (Password) String

func (p Password) String() string

func (Password) Validate

func (p Password) Validate(password string) error

type RefreshToken

type RefreshToken struct {
	ID       int64          `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	AdminID  int64          `json:"adminID,omitempty" yaml:"adminID,omitempty" required:"true"`
	Token    string         `json:"token,omitempty" yaml:"token,omitempty" required:"true"`
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
	Created  time.Time      `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated  time.Time      `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
	Expires  time.Time      `json:"expires,omitempty" yaml:"expires,omitempty" required:"true"`
}

func (RefreshToken) GetID

func (t RefreshToken) GetID() int64

type Session

type Session struct {
	AccessToken  string `json:"accessToken" required:"true"`
	RefreshToken string `json:"refreshToken" required:"true"`
}

Jump to

Keyboard shortcuts

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