Hashing password

Using postgres' pgcrypt
This commit is contained in:
cdricms
2025-01-17 10:39:59 +01:00
parent 89f44f4469
commit fdc3122b68
7 changed files with 88 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ func HandleCreateBlog(w http.ResponseWriter, r *http.Request) {
}.Respond(w, http.StatusMethodNotAllowed)
return
}
body, err := io.ReadAll(r.Body)
if err != nil {
core.JSONError{
@@ -26,16 +26,16 @@ func HandleCreateBlog(w http.ResponseWriter, r *http.Request) {
}.Respond(w, http.StatusNoContent)
return
}
var blog core.Blog
var blog core.Blog
if err = json.Unmarshal(body, &blog); err != nil {
core.JSONError{
Status: core.Error,
Message: err.Error(),
}.Respond(w, http.StatusNoContent)
return
}
}
_, err = core.DB.NewInsert().Model(blog).Exec(context.Background())
_, err = core.DB.NewInsert().Model(blog).Exec(context.Background())
if err != nil {
core.JSONError{
Status: core.Error,
@@ -46,6 +46,6 @@ func HandleCreateBlog(w http.ResponseWriter, r *http.Request) {
core.JSONSuccess{
Status: core.Success,
Message: "Blog inserted",
Data: blog,
Data: blog,
}.Respond(w, http.StatusCreated)
}