Browse Source

Validate mail address on user creation

master
Shyim 6 years ago
parent
commit
d91d394af6
  1. 13
      src/Command/CreateUserCommand.php
  2. 2
      src/Controller/Streams.php

13
src/Command/CreateUserCommand.php

@ -10,7 +10,6 @@ use Symfony\Component\Console\Output\OutputInterface; @@ -10,7 +10,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
/**
@ -53,7 +52,17 @@ class CreateUserCommand extends Command implements ContainerAwareInterface @@ -53,7 +52,17 @@ class CreateUserCommand extends Command implements ContainerAwareInterface
$io = new SymfonyStyle($input, $output);
$username = $io->ask('What should be the username?');
$email = $io->ask('What should be the email?');
do {
$email = $io->ask('What should be the email?');
$valid = (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$valid) {
$io->error('Invalid email address');
}
} while(!$valid);
$password = $io->askHidden('What should be the password?');
$user = new User();

2
src/Controller/Streams.php

@ -297,6 +297,6 @@ class Streams extends Controller @@ -297,6 +297,6 @@ class Streams extends Controller
*/
private function isValidString(?string $string)
{
return preg_match('/^[a-z|A-Z|a-z|A-Z|0-9|.|\-|_|]+$/', $string);
return preg_match('/^[a-z|A-Z|a-z|A-Z|0-9|.|\-|_|\{|\}|\:|\/]+$/', $string);
}
}
Loading…
Cancel
Save