Documentation ¶
Overview ¶
Package helpers implements different helper functions used in other areas of the project helpers/environemnt_handler.go impelements handlers used to interact with env vars.
Index ¶
- Variables
- func Authentication() gin.HandlerFunc
- func GenerateAllTokens(email string, name string, isAdmin bool) (signedToken string, signedRefreshToken string, err error)
- func GetMongoURL() string
- func GetPort() string
- func GetRefreshTokenDuration() int64
- func GetSecretKey() string
- func GetTokenDuration() int64
- func UpdateAllTokens(signedToken string, signedRefreshToken string, userId string)
- type SignedDetails
Constants ¶
This section is empty.
Variables ¶
var TESTING_KEY string = ""
Functions ¶
func Authentication ¶
func Authentication() gin.HandlerFunc
func GenerateAllTokens ¶
func GenerateAllTokens(email string, name string, isAdmin bool) (signedToken string, signedRefreshToken string, err error)
GenerateAllTokens generates both the detailed token and refresh token
func GetMongoURL ¶
func GetMongoURL() string
GetMongoURL returns a Go string representing the URL for connecting to the MongoDB
func GetPort ¶
func GetPort() string
GetPort returns a Go string that represents the PORT that will be set up for the API It's default value is 8000
func GetRefreshTokenDuration ¶
func GetRefreshTokenDuration() int64
GetRefreshTokenDuration returns a go int64 that represents how long the refresh token should last
func GetSecretKey ¶
func GetSecretKey() string
GetSecretKey returns a Go String that represents the SECRET_KEY used in JWT enconding
func GetTokenDuration ¶
func GetTokenDuration() int64
GetTokenDuration returns a Go int64 that represents how long the original token should last
func UpdateAllTokens ¶
UpdateAllTokens renews the user tokens when they login
Types ¶
type SignedDetails ¶
type SignedDetails struct { Email string Name string IsAdmin bool jwt.StandardClaims }
A SignedDetails holds an email and it's encoded counterpart using JWT
func ValidateToken ¶
func ValidateToken(signedToken string) (claims *SignedDetails, msg string)
ValidateToken validates the jwt token