utils

package
v0.0.0-...-e05cf37 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMTPServer = "smtp.pobox.com"
)

GMail smtp server

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(username, password string) (*entity.User, error)

Authenticate authenticates the user

func CreateToken

func CreateToken(u entity.User) (string, error)

CreateToken create a jwt token

func GeneratePassword

func GeneratePassword(passwordLength, minSpecialChar, minNum, minUpperCase int) string

GeneratePassword will generate a password on the minimum length

func RemoveContents

func RemoveContents(dir string) error

RemoveContents removes the contents of a directory

Types

type Authorizer

type Authorizer struct {
	User     string
	Password string
}

Authorizer is the sender of the message

func NewAuthorizer

func NewAuthorizer(Username, Password string) Authorizer

NewAuthorizer creates a new sender

func (Authorizer) SendMail

func (a Authorizer) SendMail(Dest []string, sender, Subject, bodyMessage string)

SendMail sends a basic message

func (*Authorizer) WriteHTMLEmail

func (a *Authorizer) WriteHTMLEmail(dest []string, from, subject, bodyMessage string) string

WriteHTMLEmail composes the body of the message as an HTML email

func (*Authorizer) WritePlainEmail

func (a *Authorizer) WritePlainEmail(dest []string, from, subject, bodyMessage string) string

WritePlainEmail composes the body of the message as plain text

type Claims

type Claims struct {
	Username    string `json:"username"`
	Password    string `json:"password"`
	FullName    string `json:"fullname"`
	DisplayName string `json:"displayname"`
	jwt.StandardClaims
}

Claims defines the keys we want to put in the JWT token

func DecodeToken

func DecodeToken(t string) (*Claims, error)

DecodeToken decodes a JWT token

Jump to

Keyboard shortcuts

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