Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PostCheckAuthHandler ¶
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 ¶
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 ¶
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.
Types ¶
type CustomClaims ¶
type CustomClaims struct { Role string `json:"role"` jwt.StandardClaims }
CustomClaims represents the structure of the JSON Web Token claims
type LoginRequest ¶
LoginRequest represents the HTTP request when a user attempts to log in