helper

package
v0.0.0-...-f04ff8b Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(password, hash string) error

ComparePassword compares a password with its hash

func GenerateToken

func GenerateToken(userID uint, username, role string) (string, error)

GenerateToken generates a JWT token for a user

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password using bcrypt

func InitJWT

func InitJWT(secret string, expiryHours int)

InitJWT initializes JWT configuration

Types

type JWTClaims

type JWTClaims struct {
	UserID   uint   `json:"user_id"`
	Username string `json:"username"`
	Role     string `json:"role"`
	jwt.RegisteredClaims
}

func ValidateToken

func ValidateToken(tokenString string) (*JWTClaims, error)

ValidateToken validates a JWT token and returns the claims

Jump to

Keyboard shortcuts

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