diff --git a/internal/user/routes.go b/internal/user/routes.go index eb7f80f..44bca33 100644 --- a/internal/user/routes.go +++ b/internal/user/routes.go @@ -6,6 +6,7 @@ import ( "net/http" "gitea.local/admin/hspguard/internal/repository" + "gitea.local/admin/hspguard/internal/util" "gitea.local/admin/hspguard/internal/web" "github.com/go-chi/chi/v5" ) @@ -51,10 +52,16 @@ func (h *UserHandler) register(w http.ResponseWriter, r *http.Request) { return } + hash, err := util.HashPassword(params.Password) + if err != nil { + web.Error(w, "failed to create user account", http.StatusInternalServerError) + return + } + id, err := h.repo.InsertUser(context.Background(), repository.InsertUserParams{ FullName: params.FullName, Email: params.Email, - PasswordHash: params.Password, + PasswordHash: hash, IsAdmin: false, }) if err != nil {