Documentation
¶
Index ¶
- Variables
- func CreateToken(email string) (string, error)
- func ValidateEmail(email string) error
- func ValidateLoginData(user *inputs.LoginUser) error
- func ValidateName(Name string) error
- func ValidatePassword(password string) error
- func ValidateSignupData(user *inputs.InputUser) error
- func ValidateUsername(Username string) error
- func VerifyToken(tokenString string) error
Constants ¶
This section is empty.
Variables ¶
var SecretKey = []byte(os.Getenv("SECRET_KEY"))
Functions ¶
func CreateToken ¶
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 ¶
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 ¶
ValidateLoginData compins all the input validation in on function
func ValidateName ¶
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 ¶
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 ¶
ValidateSignupData compins all the input validation in on function
func ValidateUsername ¶
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 ¶
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.