features/working-on-scopes #13

Merged
jtom38 merged 28 commits from features/working-on-scopes into main 2024-04-04 15:31:54 -07:00
Showing only changes of commit 373f7da678 - Show all commits

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
"go-cook/api/domain" "go-cook/api/domain"
"go-cook/api/repositories" "go-cook/api/repositories"
"log"
"net/http" "net/http"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
@ -12,11 +11,11 @@ import (
) )
const ( const (
ErrJwtMissing = "auth token is missing" ErrJwtMissing = "auth token is missing"
ErrJwtClaimsMissing = "claims missing on token" ErrJwtClaimsMissing = "claims missing on token"
ErrJwtExpired = "auth token has expired" ErrJwtExpired = "auth token has expired"
ErrJwtScopeMissing = "required scope is missing" ErrJwtScopeMissing = "required scope is missing"
ErrUserNotFound = "requested user does not exist" ErrUserNotFound = "requested user does not exist"
ErrUsernameAlreadyExists = "the requested username already exists" 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 { func (h *Handler) AuthLogin(c echo.Context) error {
formValues, err := c.FormParams() username := c.FormValue("name")
if err != nil { password := c.FormValue("password")
h.InternalServerErrorResponse(c, err.Error())
}
log.Println(formValues)
username := formValues.Get("name")
password := formValues.Get("password")
// Check to see if they are trying to login with the admin token // Check to see if they are trying to login with the admin token
if username == "" { if username == "" {
@ -75,7 +69,7 @@ func (h *Handler) AuthLogin(c echo.Context) error {
} }
// check if the user exists // check if the user exists
err = h.UserService.DoesUserExist(username) err := h.UserService.DoesUserExist(username)
if err != nil { if err != nil {
return h.InternalServerErrorResponse(c, err.Error()) return h.InternalServerErrorResponse(c, err.Error())
} }