Compare commits

..

2 Commits

Author SHA1 Message Date
baec55b8a9 code format 2024-04-12 15:43:30 -07:00
c5a32c68a5 login now returns json with token info 2024-04-12 15:43:00 -07:00
4 changed files with 15 additions and 3 deletions

View File

@ -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"`

View File

@ -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 {

View File

@ -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
}

View File