modified: internal/service/user_service.go
fix bag add one more check for exits user when creat user
This commit is contained in:
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"serv_golang_rest_api/internal/model"
|
||||
"serv_golang_rest_api/internal/repository"
|
||||
|
||||
@@ -20,7 +19,7 @@ func NewUserService(userRepo *repository.UserRepository) *UserService {
|
||||
func (s *UserService) CreateUser(req *model.CreateUserRequest) (*model.UserResponse, error) {
|
||||
// Проверяем существует ли пользователь с таким email
|
||||
existingUser, err := s.userRepo.FindByEmail(req.Email)
|
||||
if err.Error() != "record not found" {
|
||||
if err.Error() != "record not found" && existingUser.Email == "" {
|
||||
return nil, errors.New("user with this email already exists")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user