helpers

package
v0.0.0-...-0836f1a Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JWT_SECRET string = config.GetEnv("JWT_SECRET", "not-so-secret")

Functions

func CheckDuplicateFields

func CheckDuplicateFields(ctx context.Context, email *string, phone *string) (bool, error)

func FindUserByEmail

func FindUserByEmail(ctx context.Context, email *string, user *models.User) error

func FindUserByID

func FindUserByID(ctx context.Context, userId string, user *models.User) error

func GenerateAllTokens

func GenerateAllTokens(email, firstName, lastName, uid string) (string, string, error)

func GenerateToken

func GenerateToken(email, firstName, lastName, uid string, duration time.Duration) (string, error)

func GetNonNilString

func GetNonNilString(s *string, defaultValue string) string

func GetOrGenerateTokens

func GetOrGenerateTokens(user models.User) (string, string, error)

func GetPaginatedFoodItems

func GetPaginatedFoodItems(ctx context.Context, skip int64, recordPerPage int64) ([]models.Food, int64, error)

func GetPaginatedUsers

func GetPaginatedUsers(ctx context.Context, skip int64, recordPerPage int64) ([]models.User, int64, error)

func GetPaginationParams

func GetPaginationParams(c *gin.Context) (int64, int64)

func HashPassword

func HashPassword(password *string) *string

func InTimeSpan

func InTimeSpan(start, end, check time.Time) bool

func OrderItemOrderCreator

func OrderItemOrderCreator(order models.Order, ctx context.Context) (string, error)

func RecordExists

func RecordExists(ctx context.Context, collection *mongo.Collection, field string, value interface{}) (bool, error)

func Round

func Round(num float64) int

func ToFixed

func ToFixed(num float64, precision int) float64

func UpdateAccessToken

func UpdateAccessToken(signedAccessToken, userId string) error

func UpdateAllTokens

func UpdateAllTokens(signedAccessToken, signedRefreshToken, userId string) error

func ValidateToken

func ValidateToken(tokenStr string) error

func VerifyPassword

func VerifyPassword(hashedPassword, plainPassword string) (bool, string)

Types

type SignedDetails

type SignedDetails struct {
	Email     string
	FirstName string
	LastName  string
	UID       string
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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