From 373f7da6789069654470e4f9bd99deb2875b5d72 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Mon, 1 Apr 2024 17:50:07 -0700 Subject: [PATCH] auth now uses UrlFormEncoded like it should --- api/handlers/v1/auth.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/api/handlers/v1/auth.go b/api/handlers/v1/auth.go index c4e2348..4d7475e 100644 --- a/api/handlers/v1/auth.go +++ b/api/handlers/v1/auth.go @@ -4,7 +4,6 @@ import ( "errors" "go-cook/api/domain" "go-cook/api/repositories" - "log" "net/http" "github.com/golang-jwt/jwt/v5" @@ -12,11 +11,11 @@ import ( ) const ( - ErrJwtMissing = "auth token is missing" - ErrJwtClaimsMissing = "claims missing on token" - ErrJwtExpired = "auth token has expired" - ErrJwtScopeMissing = "required scope is missing" - ErrUserNotFound = "requested user does not exist" + ErrJwtMissing = "auth token is missing" + ErrJwtClaimsMissing = "claims missing on token" + ErrJwtExpired = "auth token has expired" + ErrJwtScopeMissing = "required scope is missing" + ErrUserNotFound = "requested user does not exist" ErrUsernameAlreadyExists = "the requested username already exists" ) @@ -61,13 +60,8 @@ func (h *Handler) AuthRegister(c echo.Context) error { } func (h *Handler) AuthLogin(c echo.Context) error { - formValues, err := c.FormParams() - if err != nil { - h.InternalServerErrorResponse(c, err.Error()) - } - log.Println(formValues) - username := formValues.Get("name") - password := formValues.Get("password") + username := c.FormValue("name") + password := c.FormValue("password") // Check to see if they are trying to login with the admin token if username == "" { @@ -75,7 +69,7 @@ func (h *Handler) AuthLogin(c echo.Context) error { } // check if the user exists - err = h.UserService.DoesUserExist(username) + err := h.UserService.DoesUserExist(username) if err != nil { return h.InternalServerErrorResponse(c, err.Error()) }