more optimization

This commit is contained in:
konrad 2018-07-11 00:28:53 +02:00 committed by kolaente
parent 237874eda6
commit e97fa30202
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 27 additions and 28 deletions

View file

@ -32,14 +32,13 @@ func Login(c echo.Context) error {
// "403": // "403":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
u := new(models.UserLogin) u := models.UserLogin{}
if err := c.Bind(u); err != nil { if err := c.Bind(&u); err != nil {
return c.JSON(http.StatusBadRequest, models.Message{"Please provide a username and password."}) return c.JSON(http.StatusBadRequest, models.Message{"Please provide a username and password."})
} }
// Check user // Check user
user, err := models.CheckUserCredentials(u) user, err := models.CheckUserCredentials(&u)
if err != nil { if err != nil {
return c.JSON(http.StatusUnauthorized, models.Message{"Wrong username or password."}) return c.JSON(http.StatusUnauthorized, models.Message{"Wrong username or password."})
} }

View file

@ -31,9 +31,9 @@ import (
"github.com/labstack/echo/middleware" "github.com/labstack/echo/middleware"
"git.kolaente.de/konrad/list/models" "git.kolaente.de/konrad/list/models"
crud "git.kolaente.de/konrad/list/routes/crud"
apiv1 "git.kolaente.de/konrad/list/routes/api/v1" apiv1 "git.kolaente.de/konrad/list/routes/api/v1"
_ "git.kolaente.de/konrad/list/routes/api/v1/swagger" // for docs generation _ "git.kolaente.de/konrad/list/routes/api/v1/swagger" // for docs generation
"git.kolaente.de/konrad/list/routes/crud"
) )
// NewEcho registers a new Echo instance // NewEcho registers a new Echo instance