package handler import ( "astra-users/model" "crypto/sha256" "fmt" "github.com/labstack/echo/v4" "net/http" ) func (h *Handler) Login(c echo.Context) (err error) { // Bind u := new(model.User) if err = c.Bind(u); err != nil { return } u.Password = fmt.Sprintf("%x", sha256.Sum256([]byte(u.Password))) var t = h.DB.Where("user_name = ? AND password = ?", u.UserName, u.Password).First(&u) if t.RowsAffected == 0 { return c.NoContent(http.StatusNotFound) } u.Password = "" return c.JSON(http.StatusOK, u) }