auth

package
v0.0.0-...-5961fbe Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostCheckAuthHandler

func PostCheckAuthHandler(c *gin.Context)

PostCheckAuthHandler handles POST requests to the /check-auth authentication API endpoint. It checks if the request contains the Authorization token. If the token exists and is valid, this handler responds with a StatusOK response code. Otherwise, this handler responds with a StatusUnauthorized response code.

func PostRegisterPilgrimHandler

func PostRegisterPilgrimHandler(c *gin.Context)

PostRegisterPilgrimHandler handles POST requests to the /register/pilgrim authentication API endpoint. It hashes the password provided and stores the details of the new user in the database. If registration is successful, this handler responds with a StatusOK response code. Otherwise, this handler responds with a StatusBadRequest response code.

func PostValidateCredentialsHandler

func PostValidateCredentialsHandler(c *gin.Context)

PostValidateCredentialsHandler handles POST requests to the /login authentication API endpoint. It compares the username and password provided to the credentials stored in the database. If a match is found, this handler responds with a StatusOK response code and an authorization token with the corresponding role. Otherwise, this handler responds with a StatusUnauthorized response code.

func RegisterInnkeeper

func RegisterInnkeeper(username string, email string, password string) error

RegisterInnkeeper registers an innkeeper account into the database

Types

type CustomClaims

type CustomClaims struct {
	Role string `json:"role"`
	jwt.StandardClaims
}

CustomClaims represents the structure of the JSON Web Token claims

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

LoginRequest represents the HTTP request when a user attempts to log in

Jump to

Keyboard shortcuts

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