Documentation ¶
Overview ¶
Package util provides some useful utility functions
Index ¶
- Constants
- func ComparePasswords(hashedPasswd string, plainPasswd string) bool
- func Decrypt(encryptedText string) (string, error)
- func Encrypt(text string) (string, error)
- func GetUserIDFromToken(rdb *redis.Client, token string, prefix string) (string, func() error, error)
- func HashPassword(passwd string) (string, error)
- func LoadEnv(verify bool) error
- func SendEmail(rdb *redis.Client, userID, email, prefix, endpoint string) error
Constants ¶
const ConfirmEmailPrefix = "confirm-email:"
ConfirmEmailPrefix is the string that is prefixed before the actual confirm email token while storing in redis so that it will be easily identifiable and it will not collide with any other key
const ExpirationDuration = 24 * time.Hour
ExpirationDuration is the duration after which the email link expires
const ForgotPasswordPrefix = "forgot-password:"
ForgotPasswordPrefix is the string that is prefixed before the actual forgot password token while storing in redis so that it will be easily identifiable and it will not collide with any other key
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶
ComparePasswords compares a hashed password with plain string password and returns a boolean representing whether the passwords match or not
func Decrypt ¶
Decrypt decrypts a base64 string using the secret key and returns the plaintext string
func GetUserIDFromToken ¶
func GetUserIDFromToken(rdb *redis.Client, token string, prefix string) (string, func() error, error)
GetUserIDFromToken first decrypts the provided token with the secret key and then looks up the user id of the key in redis and returns it
func HashPassword ¶
HashPassword hashed the given password using bcrypt and returns the string form of the hashed password
Types ¶
This section is empty.