utils

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

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecretKey = []byte(os.Getenv("SECRET_KEY"))

Functions

func CreateToken

func CreateToken(email string) (string, error)

CreateToken creates a JWT token that is valid for 24 hours and contains the provided username. The token is signed with the secret key. Returns an error if the username is empty.

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail checks if the provided email address is valid. The email must follow the pattern of a standard email address and must be between 3 and 32 characters long. Returns an error if the email is invalid.

func ValidateLoginData

func ValidateLoginData(user *inputs.LoginUser) error

ValidateLoginData compins all the input validation in on function

func ValidateName

func ValidateName(Name string) error

ValidateName checks if the provided Name is valid. The Name must be between 3 and 32 characters long and may contain alphanumeric characters and the following special characters: !@#$%^&*()_+={}\[\]:;,.<>?/- Returns an error if the Name is invalid.

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword checks if the password is valid. The password must be at least 8 characters long, must contain at least one uppercase letter and one number, and may contain the following characters: A-Z, a-z, 0-9, _, !, @, #, $, ^, &, *, (, ), and +. Returns an error if the password is invalid.

func ValidateSignupData

func ValidateSignupData(user *inputs.InputUser) error

ValidateSignupData compins all the input validation in on function

func ValidateUsername

func ValidateUsername(Username string) error

ValidateUsername checks if the provided Username is valid. The Username must be between 3 and 32 characters long and may contain alphanumeric characters and the following special characters: !@#$%^&*()_+={[]}:;,.<>?/- Returns an error if the Username is invalid.

func VerifyToken

func VerifyToken(tokenString string) error

VerifyToken takes a JWT token and verifies its validity. If the token is valid, it returns nil. If the token is invalid, it returns an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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