utils

package
v0.0.0-...-29cd555 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryStringToDecimal

func BinaryStringToDecimal(binString string) (int, error)

BinaryStringToDecimal Convert binary string like "10111" to decimal number

func CheckPasswordHash

func CheckPasswordHash(hash, password string) bool

CheckPasswordHash Check user's password in login step

func Create2faURL

func Create2faURL(email, secret string) (string, error)

Create2faURL Create URL for 2FA application

func CreateOtpSecret

func CreateOtpSecret() (string, error)

func CreateOtpURL

func CreateOtpURL(email, secret string) (string, error)

func CreateQRCode

func CreateQRCode(data2code string) ([]byte, error)

CreateQRCode Creates QR code image for 2FA

func Divmod

func Divmod(numerator, denominator int) (quotient, remainder int)

func GeneratePasswordHash

func GeneratePasswordHash(password string) (string, error)

GeneratePasswordHash Create hash from user's given password to save in database Using bcrypt package to create hash at the default cost

func ParseMailTemplate

func ParseMailTemplate(name string, params map[string]interface{}) (string, error)

func VerifyOTP

func VerifyOTP(token, secret string) error

Types

type MailMessage

type MailMessage struct {
	To          []string
	Copy        []string
	Subject     string
	Body        string
	Attachments map[string][]byte
}

func (*MailMessage) Attach

func (m *MailMessage) Attach(filename string, body []byte)

type Mailer

type Mailer struct {
	Auth smtp.Auth
	Addr string
	From string
}

func NewMailer

func NewMailer() *Mailer

func (*Mailer) Send

func (m *Mailer) Send(message *MailMessage) error

type Paginator

type Paginator struct {
	Page    uint
	PerPage uint
	OrderBy string
	RawURL  string
	Totals  int64
}

func NewPaginator

func NewPaginator(data dto.BaseSearchRequestDto) *Paginator

func (*Paginator) GetLimit

func (p *Paginator) GetLimit() uint

func (*Paginator) GetOffset

func (p *Paginator) GetOffset() uint

func (*Paginator) GetTotalPages

func (p *Paginator) GetTotalPages() uint
func (p *Paginator) MakeFirstLink() string
func (p *Paginator) MakeLastLink() string
func (p *Paginator) MakeNextLink() string
func (p *Paginator) MakePrevLink() string

func (*Paginator) ToLinkHeader

func (p *Paginator) ToLinkHeader() string

func (*Paginator) ToRepresentation

func (p *Paginator) ToRepresentation() dto.PaginationInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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