utils

package
v0.0.0-...-702c875 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AccessTokenKey = "access_token"

Variables

View Source
var (
	TimeFiveMinutes = time.Now().Add(5 * time.Minute)
	TimeOneMonth    = time.Now().Add(30 * 24 * time.Hour)
)

move to const time variables

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GenerateTokens

func GenerateTokens(userId pgtype.UUID) (accessToken string, refreshToken string, err error)

func HashPassword

func HashPassword(password string) (string, error)

func IsTokenExpired

func IsTokenExpired(claims *CustomClaims) bool

func LoadEnv

func LoadEnv()

Types

type Credentials

type Credentials struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func GetValidCredentials

func GetValidCredentials(c fiber.Ctx) (*Credentials, error)

type CustomClaims

type CustomClaims struct {
	jwt.RegisteredClaims
	Exp    string      `json:"exp"`
	UserId pgtype.UUID `json:"userId"`
}

func ValidateToken

func ValidateToken(tokenStr string) (*CustomClaims, error)

Jump to

Keyboard shortcuts

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