helpers

package
v0.0.0-...-c86d00c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTokenMatch

func CheckTokenMatch(db *gorm.DB, userId int64, token string) bool

CheckTokenMatch checks if a token and a userId match

func CheckUnique

func CheckUnique(db *gorm.DB, column string, value any, tableName string) bool

CheckUnique checks if any value is unique in a table

func GenerateCode

func GenerateCode() (int, error)

GenerateCode generates a 6-digit code

func GenerateToken

func GenerateToken() string

GenerateToken generates a secure random token

func GetUserFromToken

func GetUserFromToken(db *gorm.DB, token string) (handlers.User, error)

GetUserFromToken returns the user associated with the given token

func IsEmailValid

func IsEmailValid(email string) (bool, error)

func RespondError

func RespondError(w http.ResponseWriter, message any, status int)

RespondError returns an error message as response

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, message string)

RespondJSON function to return JSON message as response (mainly used on success)

func UsersExist

func UsersExist(userIds []int64, db *gorm.DB) bool

UsersExist just checks if given userIds are in the database

Types

This section is empty.

Jump to

Keyboard shortcuts

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