models

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 10 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 Log added in v0.0.26

type Log struct {
	Model
	User      *User     `json:"user,omitempty" gorm:"foreignKey:UserUUID;constraint:OnUpdate:CASCADE"`
	UserUUID  uuid.UUID `json:"userUUID" gorm:"not null;"`
	Action    string    `json:"action" gorm:"not null"`
	IpAddress string    `json:"ipaddr" gorm:"not null"`
	LogTime   time.Time `json:"logTime" gorm:"not null;default:CURRENT_TIMESTAMP"`
}

func RandomLog added in v0.0.26

func RandomLog() (*Log, string)

type Model added in v0.0.19

type Model struct {
	UUID      uuid.UUID  `json:"uuid,omitempty" 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,omitempty" gorm:"unique;not null;"`
	Password     string  `json:"password,omitempty" 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