splitted user registration into user, consents & bankaccount creation

This commit is contained in:
$(pass /github/name)
2024-07-07 21:39:58 +02:00
parent a76d73aa82
commit 555d1be575
13 changed files with 270 additions and 53 deletions

View File

@@ -4,9 +4,9 @@ import (
"GoMembership/internal/models"
"GoMembership/internal/repositories"
// "GoMembership/pkg/errors"
"crypto/rand"
"encoding/base64"
"golang.org/x/crypto/bcrypt"
// "crypto/rand"
// "encoding/base64"
// "golang.org/x/crypto/bcrypt"
"time"
)
@@ -24,7 +24,7 @@ func NewUserService(repo repositories.UserRepository) UserService {
}
func (service *userService) RegisterUser(user *models.User) (int64, error) {
salt := make([]byte, 16)
/* salt := make([]byte, 16)
if _, err := rand.Read(salt); err != nil {
return -1, err
}
@@ -34,21 +34,21 @@ func (service *userService) RegisterUser(user *models.User) (int64, error) {
if err != nil {
return -1, err
}
user.Password = string(hashedPassword)
user.Password = string(hashedPassword) */
user.Password = ""
user.CreatedAt = time.Now()
user.UpdatedAt = time.Now()
user.MandateDateSigned = time.Now()
return service.repo.CreateUser(user)
}
func HashPassword(password string, salt string) (string, error) {
/* func HashPassword(password string, salt string) (string, error) {
saltedPassword := password + salt
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(saltedPassword), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(hashedPassword), nil
}
} */
/* func (s *userService) AuthenticateUser(email, password string) (*models.User, error) {
user, err := s.repo.FindUserByEmail(email)