Commit 37195eb6 authored by Moreau Elise's avatar Moreau Elise
Browse files

solve bug when email or username already in use

parent e0b53901
......@@ -5,7 +5,8 @@ namespace App\Application\Actions\User;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use App\Domain\User\User ;
use App\Domain\User\User;
use GeoIp2\Database\Reader;
use DateTime;
class CreateUserAction extends UserAction
......@@ -44,6 +45,40 @@ class CreateUserAction extends UserAction
);
}
if ($this->userRepository->findOneBy(array('username' => $username))){
return $this->twig->render(
$this->response, "/user/create_user.twig",
array(
"username" => $username,
"firstname" => $firstname,
"lastname" => $lastname,
"mail" => $mail,
"contaminated" => $contaminated,
"password" => null,
"confirmpassword" => null,
"message" => "Username already used",
"formstatus" => "error"
)
);
}
if ($this->userRepository->findOneBy(array('mail' => $mail))){
return $this->twig->render(
$this->response, "/user/create_user.twig",
array(
"username" => $username,
"firstname" => $firstname,
"lastname" => $lastname,
"mail" => $mail,
"contaminated" => $contaminated,
"password" => null,
"confirmpassword" => null,
"message" => "Mail already used",
"formstatus" => "error"
)
);
}
$password = password_hash($password, PASSWORD_DEFAULT);
$date = new DateTime('now');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment