model

package
v0.0.0-...-a9bc940 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func ConnectDatabase

func ConnectDatabase()

func ExtractToken

func ExtractToken(c *gin.Context) string

func ExtractTokenID

func ExtractTokenID(c *gin.Context) (uint, error)

func GenerateToken

func GenerateToken(user_id uint) (string, error)

func JwtAuthMiddleware

func JwtAuthMiddleware() gin.HandlerFunc

func LoginCheck

func LoginCheck(username string, password string) (string, error)

func TokenValid

func TokenValid(c *gin.Context) error

func VerifyPassword

func VerifyPassword(password, hashedPassword string) error

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Claims represents the JWT claims

type License

type License struct {
	ID        uint   `json:"id" gorm:"primary_key"`
	ShortName string `json:"shortname"`
	LongName  string `json:"longname"`
	Url       string `json:"url"`
}

type LicenseInput

type LicenseInput struct {
	ShortName string `json:"shortname" binding:"required"`
	LongName  string `json:"longname" binding:"required"`
	Url       string `json:"url" binding:"required"`
}

type User

type User struct {
	gorm.Model
	Username string `gorm:"size:255;not null;unique" json:"username"`
	Password string `gorm:"size:255;not null;" json:"password"`
}

func GetUserByID

func GetUserByID(uid uint) (User, error)

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) PrepareGive

func (u *User) PrepareGive()

func (*User) SaveUser

func (u *User) SaveUser() (*User, error)

Jump to

Keyboard shortcuts

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