userservice

package
v0.0.0-...-9340d71 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash - Returns true if hash and password matches else returms false

func CreateNewUser

func CreateNewUser(firstname string, lastname string, email string, hash string) bool

CreateNewUser - Saves new user in DB

func DecryptToken

func DecryptToken(key []byte, securemess string) (decodedmess string, err error)

DecryptToken - Decrypts the user token

func EncryptToken

func EncryptToken(key []byte, message string) (encmess string, err error)

EncryptToken - Encrypts the user token

func HashPassword

func HashPassword(password string) (string, error)

HashPassword - Generates a Hash value for the passord

func IsLetter

func IsLetter(s string) bool

IsLetter - checks if a string only contains alphabets or not.

func RespondWithError

func RespondWithError(c *gin.Context, code int, message interface{})

RespondWithError - Error response returner

func UserAuthentication

func UserAuthentication() gin.HandlerFunc

UserAuthentication - middleware to check user authentication

func UserDetails

func UserDetails(c *gin.Context)

UserDetails - Returns the basic user details

func UserLogin

func UserLogin(c *gin.Context)

UserLogin - Logins the user if the user is authorised.

func UserLogout

func UserLogout(c *gin.Context)

UserLogout - Logouts a user from the application

func UserRegistration

func UserRegistration(c *gin.Context)

UserRegistration - Registers a user account

Types

type JWTData

type JWTData struct {
	ID               uint
	FirstName        string
	LastName         string
	Email            string
	IsActive         bool
	IsAdmin          bool
	TokenGeneratedAt *time.Time
}

JWTData - Struct to store data passed through auth request

Jump to

Keyboard shortcuts

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