From d91d394af6ee0119669106b419c0c3883d927a8b Mon Sep 17 00:00:00 2001 From: Shyim Date: Thu, 26 Apr 2018 13:41:50 +0200 Subject: [PATCH] Validate mail address on user creation --- src/Command/CreateUserCommand.php | 13 +++++++++++-- src/Controller/Streams.php | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php index 084ab66..3547131 100644 --- a/src/Command/CreateUserCommand.php +++ b/src/Command/CreateUserCommand.php @@ -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 $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(); diff --git a/src/Controller/Streams.php b/src/Controller/Streams.php index c2483e5..59d0e7b 100644 --- a/src/Controller/Streams.php +++ b/src/Controller/Streams.php @@ -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); } } \ No newline at end of file