utils

package
v0.0.0-...-7ccf317 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RUNES = []rune("0123456789")

Functions

func BuildMessage

func BuildMessage(mail Mail) string

func ComparePassword

func ComparePassword(hashedPassword string, password string) bool

func GenerateVerificationCode

func GenerateVerificationCode() string

func HashPassword

func HashPassword(password string) string

func RefreshJWT

func RefreshJWT(token string, addTime time.Duration) (string, error)

func SendMail

func SendMail(to []string, body string, subject string) error

func SignJWT

func SignJWT(c *Claims) string

Types

type Claims

type Claims struct {
	Subject  string           `json:"sub"`
	Iat      int64            `json:"iat"`
	Nbf      int64            `json:"nbf"`
	Issuer   string           `json:"iss"`
	Audience jwt.ClaimStrings `json:"aud"`
	Exp      int64            `json:"exp"`
}

func VerifyJWT

func VerifyJWT(token string) (*Claims, error)

func (*Claims) GetAudience

func (c *Claims) GetAudience() (jwt.ClaimStrings, error)

func (*Claims) GetExpirationTime

func (c *Claims) GetExpirationTime() (*jwt.NumericDate, error)

func (*Claims) GetIssuedAt

func (c *Claims) GetIssuedAt() (*jwt.NumericDate, error)

func (*Claims) GetIssuer

func (c *Claims) GetIssuer() (string, error)

func (*Claims) GetNotBefore

func (c *Claims) GetNotBefore() (*jwt.NumericDate, error)

func (*Claims) GetSubject

func (c *Claims) GetSubject() (string, error)

type Mail

type Mail struct {
	Sender  string
	To      []string
	Subject string
	Body    string
}

Jump to

Keyboard shortcuts

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