more optimization
This commit is contained in:
parent
237874eda6
commit
e97fa30202
3 changed files with 27 additions and 28 deletions
|
@ -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."})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue