From 413e35101c650937482c7212f22d7da37f52cbdc Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Wed, 14 Aug 2024 11:34:57 +0500 Subject: [PATCH] fix bag with save uder 00 uuid --- api/src/auth/Registr.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/api/src/auth/Registr.go b/api/src/auth/Registr.go index 6b7c986..c8748a8 100644 --- a/api/src/auth/Registr.go +++ b/api/src/auth/Registr.go @@ -6,6 +6,8 @@ import ( "encoding/json" "net/http" + "github.com/google/uuid" + "golang.org/x/crypto/bcrypt" ) @@ -23,11 +25,15 @@ func Register(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) return } + + id := uuid.New() + user := models.User{ - Name: Crenetials.Name, - Email: Crenetials.Email, + Id: id, + Name: Crenetials.Name, + Email: Crenetials.Email, Password: hashedPassword, - Phone: Crenetials.Phone, + Phone: Crenetials.Phone, } if result := psql.PSQL_GORM_DB.Create(&user); result.Error != nil { w.WriteHeader(http.StatusInternalServerError) @@ -37,6 +43,6 @@ func Register(w http.ResponseWriter, r *http.Request) { } func hashPassword(password string) (string, error) { - bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14) - return string(bytes), err + bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14) + return string(bytes), err }