entities

package
v0.0.0-...-8bbec6a Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	UserID    string `json:"user_id"`
	Username  string `json:"username"`
	Lastname  string `json:"lastname"`
	Firstname string `json:"firstname"`
	jwt.StandardClaims
}

Claims are custom claims extending default ones

func NewClaims

func NewClaims(id, username, firstname, lastname string, lifetime int) *Claims

NewClaims creates a new Claims

func (Claims) GenerateJWT

func (c Claims) GenerateJWT(algo, secret string) (string, error)

GenerateJWT generates token

type User

type User struct {
	ID        string         `json:"id" xml:"id" form:"id" gorm:"primaryKey" validate:"required,uuid"`
	Username  string         `json:"username" xml:"username" form:"username" gorm:"unique;size:127" validate:"required,email"`
	Password  string         `json:"-" xml:"-" form:"password" gorm:"index;size=128" validate:"required,min=8"` // SHA512
	Lastname  string         `json:"lastname" xml:"lastname" form:"lastname" gorm:"size=63" validate:"required"`
	Firstname string         `json:"firstname" xml:"firstname" form:"firstname" gorm:"size=63" validate:"required"`
	CreatedAt time.Time      `json:"created_at" xml:"created_at" form:"created_at" gorm:"autoCreateTime"`
	UpdatedAt time.Time      `json:"updated_at" xml:"updated_at" form:"updated_at" gorm:"autoUpdateTime"`
	DeletedAt gorm.DeletedAt `json:"-" xml:"-" form:"deleted_at" gorm:"index"`
}

User represents a user in database.

type UserForm

type UserForm struct {
	Username  string `json:"username" xml:"username" form:"username" validate:"required,email"`
	Password  string `json:"password" xml:"password" form:"password" validate:"required,min=8"`
	Lastname  string `json:"lastname" xml:"lastname" form:"lastname" validate:"required"`
	Firstname string `json:"firstname" xml:"firstname" form:"firstname" validate:"required"`
}

UserForm is used to create or update a user.

Jump to

Keyboard shortcuts

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