utils

package
v0.0.0-...-5b3ac6b Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessToken

func GenerateAccessToken(email string, id primitive.ObjectID, role string) (string, error)

func GenerateIDs

func GenerateIDs(length int) string

func GenerateRefreshToken

func GenerateRefreshToken(email string, id primitive.ObjectID, v int) (string, error)

func HandleRequestErrors

func HandleRequestErrors()

func IsTimeBetween

func IsTimeBetween(Time time.Time, timeStart float32, timeEnd float32) bool

func VerifyPassword

func VerifyPassword(password, hashedPassword string) error

Types

type AcessTokenClaim

type AcessTokenClaim struct {
	jwt.StandardClaims
	Id    string `json:"id"`
	Email string `json:"email"`
	Role  string `json:"role"`
}

func VerifyAccessToken

func VerifyAccessToken(tokenString string) (AcessTokenClaim, error)

type ErrorResonse

type ErrorResonse struct {
	StatusCode int
	Reason     error
}

func UploadFiles

func UploadFiles(base string, files ...*multipart.FileHeader) ([]string, *ErrorResonse)

type ErrorResponse

type ErrorResponse struct {
	Status  int
	Message interface{}
}

func HandlerError

func HandlerError(err error) ErrorResponse

type RefereshTokenClaim

type RefereshTokenClaim struct {
	jwt.StandardClaims
	Id           string `json:"id"`
	Email        string `json:"email"`
	TokenVersion int    `json:"token_v"`
}

func VerifyRefereshToken

func VerifyRefereshToken(tokenString string) (*RefereshTokenClaim, error)

Jump to

Keyboard shortcuts

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