utils

package
v0.0.0-...-d11cb64 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const JWTExpirationTime time.Duration = (90 * 24) * time.Hour

JWTExpirationTime specifies the system-wide JWT expiration

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

GMail smtp server

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(username, fullname, displayname string) (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 GetEndTime

func GetEndTime(days int) time.Time

GetEndTime returns the time days from now at 11:59pm

func GetLocation

func GetLocation() *time.Location

GetLocation returns the locations for all time functions

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