fix bag with save uder 00 uuid
This commit is contained in:
+11
-5
@@ -6,6 +6,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,11 +25,15 @@ func Register(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id := uuid.New()
|
||||||
|
|
||||||
user := models.User{
|
user := models.User{
|
||||||
Name: Crenetials.Name,
|
Id: id,
|
||||||
Email: Crenetials.Email,
|
Name: Crenetials.Name,
|
||||||
|
Email: Crenetials.Email,
|
||||||
Password: hashedPassword,
|
Password: hashedPassword,
|
||||||
Phone: Crenetials.Phone,
|
Phone: Crenetials.Phone,
|
||||||
}
|
}
|
||||||
if result := psql.PSQL_GORM_DB.Create(&user); result.Error != nil {
|
if result := psql.PSQL_GORM_DB.Create(&user); result.Error != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
@@ -37,6 +43,6 @@ func Register(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func hashPassword(password string) (string, error) {
|
func hashPassword(password string) (string, error) {
|
||||||
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||||||
return string(bytes), err
|
return string(bytes), err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user