utils

package
v0.0.0-...-b985c81 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashPassword

func CompareHashPassword(password, hash string) bool

CompareHashPassword compares a password (plain string) to a hash.

func GenerateHashPassword

func GenerateHashPassword(password string) (string, error)

GenerateHashPassword generates a hash from a password.

func Preserve

func Preserve(channels []chan struct{})

Preserve is a function that listens for exit signals and closes channels. This allows us to gracefully close the application, within Docker we normally have 10 seconds to close the application before it is forcefully closed. Therefore we can use 'channels' to gracefully close areas of the application. E.g. the API server and DB.

Types

type TokenResponse

type TokenResponse struct {
	UserID       int       `json:"user_id,omitempty"`
	Token        string    `json:"token"`
	ExpiresAfter time.Time `json:"expires_after"`
}

TokenResponse is the response for a token.

func CreateTokenString

func CreateTokenString(id int) (TokenResponse, error)

CreateTokenString creates a token string for a user using JWT.

func ParseToken

func ParseToken(tokenString string) (TokenResponse, error)

ParseToken parses a token string and returns the token - checking for expiry.

Jump to

Keyboard shortcuts

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