util

package
v0.0.0-...-4c13341 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMessage

func BuildMessage(mail Mail) string

func CheckCreatedDateOfOTP

func CheckCreatedDateOfOTP(createdAt time.Time, count int16) (dayCount int16)

func CheckOtpValidation

func CheckOtpValidation(userOtp models.EmailOTP) (int64, time.Time, error)

func CheckPassword

func CheckPassword(password string, hashedPassword string) error

CheckPassword checks if the provided password is correct or not

func CreateNUllTime

func CreateNUllTime(valid bool, value time.Time) sql.NullTime

func CreateNullBool

func CreateNullBool(valid bool, value bool) sql.NullBool

func CreateNullInt16

func CreateNullInt16(valid bool, value int16) sql.NullInt16

func CreateNullInt32

func CreateNullInt32(valid bool, value int32) sql.NullInt32

func CreateNullInt64

func CreateNullInt64(valid bool, value int64) sql.NullInt64

func CreateNullString

func CreateNullString(valid bool, value string) sql.NullString

func HashPassword

func HashPassword(password string) (string, error)

HashedPassword returns the bcrypt hash of the password

func IsValidEmail

func IsValidEmail(e string) bool

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random integer between min max

func RandomOTP

func RandomOTP() int64

RandomMoney generates a random amount of money

func SendEmailVerificationCode

func SendEmailVerificationCode(param SendEmailVerificationCodeParam) error

func SetExpirationOfOTP

func SetExpirationOfOTP(count int16) (t time.Time, err error)

func VerifyOTP

func VerifyOTP(reqOtp, dbOtp int64) (b bool, err error)

func VerifyOTPExpiration

func VerifyOTPExpiration(dbOtpExp time.Time) (b bool, err error)

Types

type Config

type Config struct {
	DBDriver             string        `mapstructure:"DB_DRIVER"`
	DBSource             string        `mapstructure:"DB_SOURCE"`
	ServerAddress        string        `mapstructure:"SERVER_ADDRESS"`
	TokenSymmetricKey    string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration  time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	CountryStateAPIToken string        `mapstructure:"COUNTRY_STATE_API_TOKEN"`
	SendInBlueKey        string        `mapstructure:"SEND_IN_BLUE_KEY"`
	SendInBlueEmail      string        `mapstructure:"SEND_IN_BLUE_EMAIL"`
	SenderEmail          string        `mapstructure:"SENDER_EMAIL"`
	SendInBluePassword   string        `mapstructure:"SEND_IN_BLUE_PASSWORD"`
	SMTPHost             string        `mapstructure:"SMTP_HOST"`
}

func LoadConfig

func LoadConfig(path string) (config Config, err error)

type Mail

type Mail struct {
	Sender  string
	To      []string
	Subject string
	Body    string
}

type SendEmailVerificationCodeParam

type SendEmailVerificationCodeParam struct {
	SenderEmail        string
	SendInBlueEmail    string
	SendInBluePassword string
	SendInBlueAddress  string
	SMTPHost           string
	UserName           string
	UserEmail          string
	OTP                string
}

Encapsulation

Jump to

Keyboard shortcuts

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