exclude password

This commit is contained in:
andrusyakka
2023-07-14 18:39:09 +03:00
parent 4a6a326f6d
commit 94d2a1df2b
2 changed files with 2 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ func (h *Handler) GetUserBatch(c echo.Context) error {
return c.NoContent(http.StatusBadRequest) return c.NoContent(http.StatusBadRequest)
} }
h.DB.Find(&users, ids) h.DB.Omit("Password").Find(&users, ids)
return c.JSON(http.StatusOK, users) return c.JSON(http.StatusOK, users)
} }
@@ -60,7 +60,7 @@ func (h *Handler) GetUser(c echo.Context) error {
return c.NoContent(http.StatusBadRequest) return c.NoContent(http.StatusBadRequest)
} }
tx := h.DB.Preload("Position").Where("id = ?", id).Find(&user) tx := h.DB.Preload("Position").Omit("Password").Where("id = ?", id).Find(&user)
if tx.RowsAffected == 0 { if tx.RowsAffected == 0 {
return c.NoContent(http.StatusNotFound) return c.NoContent(http.StatusNotFound)

BIN
test.db

Binary file not shown.