util

package
v0.0.0-...-10cef3e Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserKey = ContextType("user")
)

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(password, hashedPassword string) bool

func GenerateJwtToken

func GenerateJwtToken(jwtSecret string, expires time.Duration, user *models.User) (string, error)

func GeneratePasswordHash

func GeneratePasswordHash(password string) (string, error)

func IsRAdmin

func IsRAdmin(r *http.Request) bool

IsRAdmin returns true if the user creating the request is an admin

func IsRAuthed

func IsRAuthed(r *http.Request) bool

IsRAuthed returns true if the user creating the request is authenticated

func IsRProposer

func IsRProposer(r *http.Request) bool

IsRProposer returns true if the user creating the request is a proposer

func IsTokenValid

func IsTokenValid(tokenString, jwtSecret string) error

IsTokenValid returns nil if the jwt token is valid and an error otherwise.

func User

func User(r *http.Request) *models.User

User returns a pointer to the user from request context

func VerifyToken

func VerifyToken(tokenString, jwtSecret string) (*jwt.Token, error)

Types

type ContextType

type ContextType string

Jump to

Keyboard shortcuts

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