util

package
v0.0.0-...-931afa0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) error

CheckPasswordHash checks if the provided password is correct or not

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password

Types

type TokenHandler

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

func NewTokenHandler

func NewTokenHandler(secret string, redisClient *redis.Client) TokenHandler

func (*TokenHandler) BlacklistToken

func (handler *TokenHandler) BlacklistToken(tokenString string, expiry time.Duration) error

Add token to blacklist in Redis

func (*TokenHandler) CreateToken

func (handler *TokenHandler) CreateToken(user *storage.User, duration time.Duration, tokenType string) (string, *UserClaims, error)

func (*TokenHandler) NewUserClaims

func (handler *TokenHandler) NewUserClaims(user *storage.User, duration time.Duration, tokenType string) (*UserClaims, error)

func (*TokenHandler) VerifyToken

func (handler *TokenHandler) VerifyToken(tokenString string, expectedType string) (*UserClaims, error)

type UserClaims

type UserClaims struct {
	UserID    string `json:"user_id"`
	Email     string `json:"email"`
	Role      string `json:"role"`
	TokenType string `json:"token_type"`
	jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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