From c5a32c68a5952567be4d248af1d0ec016d13aba6 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 12 Apr 2024 15:43:00 -0700 Subject: [PATCH 1/2] login now returns json with token info --- api/domain/responses.go | 7 +++++++ api/handlers/v1/auth.go | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/api/domain/responses.go b/api/domain/responses.go index 445e05c..dce4b9a 100644 --- a/api/domain/responses.go +++ b/api/domain/responses.go @@ -1,5 +1,12 @@ package domain +type LoginResponse struct { + Success bool `json:"success"` + Token string `json:"token"` + Type string `json:"type"` + RefreshToken string `json:"refreshToken"` +} + type ErrorResponse struct { Success bool `json:"success"` Message string `json:"message"` diff --git a/api/handlers/v1/auth.go b/api/handlers/v1/auth.go index 6c66cdd..209903c 100644 --- a/api/handlers/v1/auth.go +++ b/api/handlers/v1/auth.go @@ -4,8 +4,8 @@ import ( "errors" "net/http" - "git.jamestombleson.com/jtom38/go-cook/api/repositories" "git.jamestombleson.com/jtom38/go-cook/api/domain" + "git.jamestombleson.com/jtom38/go-cook/api/repositories" "github.com/golang-jwt/jwt/v5" "github.com/labstack/echo/v4" @@ -89,7 +89,12 @@ func (h *Handler) AuthLogin(c echo.Context) error { return h.InternalServerErrorResponse(c, err.Error()) } - return c.JSON(http.StatusOK, token) + return c.JSON(http.StatusOK, domain.LoginResponse{ + Success: true, + Token: token, + Type: "Bearer", + RefreshToken: "", + }) } func (h *Handler) validateAdminToken(c echo.Context, password string) error { -- 2.45.2 From baec55b8a9f74ffe1c7a7a097344a5ef294d6a7a Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 12 Apr 2024 15:43:30 -0700 Subject: [PATCH 2/2] code format --- api/services/env.go | 2 +- portal/.gitkeep | 0 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 portal/.gitkeep diff --git a/api/services/env.go b/api/services/env.go index d19ed18..7fd99a6 100644 --- a/api/services/env.go +++ b/api/services/env.go @@ -16,7 +16,7 @@ func NewEnvConfig() domain.EnvConfig { log.Println(err) } - disableMigrations, err := strconv.ParseBool(os.Getenv("DisableMigrationsOnStartup")) + disableMigrations, err := strconv.ParseBool(os.Getenv("DisableMigrationsOnStartup")) if err != nil { disableMigrations = false } diff --git a/portal/.gitkeep b/portal/.gitkeep deleted file mode 100644 index e69de29..0000000 -- 2.45.2