utils

package
v0.0.0-...-0531a73 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(secretKey []byte, userId int, role models.UserRole) (string, error)

func ErrorHandler

func ErrorHandler(c fiber.Ctx, err error) error

func HashPassword

func HashPassword(password string) (string, error)

func VerifyPassword

func VerifyPassword(password, hash string) bool

Types

type Claims

type Claims struct {
	UserId int             `json:"id"`
	Role   models.UserRole `json:"role"`
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken(secret []byte, tokenStr string) (*Claims, error)

type StructValidator

type StructValidator struct {
	// contains filtered or unexported fields
}

func NewStructValidator

func NewStructValidator() *StructValidator

func (*StructValidator) Validate

func (v *StructValidator) Validate(out any) error

type ValidationErrorDetail

type ValidationErrorDetail struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

func ParseValidationErrors

func ParseValidationErrors(err error) []ValidationErrorDetail

Jump to

Keyboard shortcuts

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