utils

package
v0.0.0-...-35b7764 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalEnv = models.Environment{}

keep env vars in runtime

Functions

func CheckPassword

func CheckPassword(plain string, hashed string) bool

check if plain string password is the equivalent of a given hash

func GeneratePassword

func GeneratePassword() string

generates a random password of 12 characters long with random uppercase and lowercase letters and random numbers

func GetRandomPfp

func GetRandomPfp(seed, path string) (string, error)

make http request and get a random SVG profile picture from given randomness seed, returns empty string if an error occurs. The name is auto-generated by the function, on the path must go only the name of the user directory,

func HashAndSalt

func HashAndSalt(password string) (string, error)

hash and salt plain string password, returns the hashed password

func LoadEnv

func LoadEnv()

use dotenv to load .env file declarations into environment variables

func RandomInt

func RandomInt(max int) int

generates a random integer number within given range including the 0

func SendEmail

func SendEmail(to []string, topic, message string) error

handles internally all the required logic to send an email by given values, it can send html mails

func ValidateEmail

func ValidateEmail(email string) bool

validate through REGEX if a string is a valid email address

func ValidateName

func ValidateName(username string) bool

check if the given string is valid to be used as username or reponame for the application (git actions, url, etc). A valid username can only: have letters, numbers and the characters - or _, have a minimum of 3 characters and maximum 25

func ValidatePassword

func ValidatePassword(password string) bool

checks if a string has at least 8 characters at least 1 number and at least one uppercase

Types

This section is empty.

Jump to

Keyboard shortcuts

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