feat: hash user's password on register
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user