helper

package
v0.0.0-...-21c6822 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidToken is returned when token validation fails
	ErrInvalidToken = errors.New("invalid token")
)

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 (uses global state) Deprecated: This function uses global state, consider refactoring to use JWTManager

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 (for backward compatibility) Deprecated: Use NewJWTManager instead

Types

type JWTClaims

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

JWTClaims represents the claims stored in a JWT token

func ValidateToken

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

ValidateToken validates a JWT token and returns the claims (uses global state) Deprecated: This function uses global state, consider refactoring to use JWTManager

Jump to

Keyboard shortcuts

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