models

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPasswordCost    = 12
	DefaultExpirationDelta = 30 * 24 * time.Hour
)

Variables

View Source
var (
	True  = true
	False = false
)

Functions

This section is empty.

Types

type Model added in v0.0.19

type Model struct {
	UUID      uuid.UUID  `json:"uuid" gorm:"primaryKey;"`
	CreatedAt time.Time  `json:"-"`
	UpdatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-" sql:"index"`
}

func (*Model) BeforeCreate added in v0.0.19

func (m *Model) BeforeCreate(tx *gorm.DB) error

type User added in v0.0.19

type User struct {
	Model
	Username     *string `json:"username" gorm:"unique;not null;"`
	Password     string  `json:"password" gorm:"-"`
	PasswordHash []byte  `json:"-" gorm:"not null;"`
}

func RandomUser added in v0.0.19

func RandomUser() *User

func (*User) Authenticate added in v0.0.19

func (u *User) Authenticate(password string) bool

func (*User) BeforeCreate added in v0.0.19

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

func (*User) BeforeSave added in v0.0.19

func (u *User) BeforeSave(tx *gorm.DB) (err error)

func (*User) Claims added in v0.0.19

func (u *User) Claims() jwt.MapClaims

func (*User) FromClaims added in v0.0.19

func (u *User) FromClaims(m jwt.MapClaims) error

Jump to

Keyboard shortcuts

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