From 6d02a4a6d1f762f369014f3fbae8dfbc72b4ce29 Mon Sep 17 00:00:00 2001 From: Shyim Date: Wed, 25 Apr 2018 18:50:25 +0200 Subject: [PATCH] Added command to create user --- .gitignore | 3 +- README.md | 2 +- config/packages/security.yaml | 2 +- public/theme/src/components/ReCast/Login.vue | 4 +- src/Command/CreateUserCommand.php | 71 ++++++++++++++++++++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/Command/CreateUserCommand.php diff --git a/.gitignore b/.gitignore index 392838c..9df3f1b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ yarn-error.log ###< symfony/web-server-bundle ### .idea -/config/jwt \ No newline at end of file +/config/jwt +/public/static \ No newline at end of file diff --git a/README.md b/README.md index 6ecf637..39ba010 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## What is ReCast? -ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. You can throught your servers to multiple services simultaneously like Twitch, YouTube, Mixer and custom RTMP. +ReCast is a multi platform streaming tool written in PHP and uses nginx RTMP. You can stream through one server to multiple services ## Installation diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 154beec..1c18fc4 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -33,4 +33,4 @@ security: - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/api, roles: IS_AUTHENTICATED_FULLY } encoders: - App\Entity\User: plaintext + App\Entity\User: bcrypt diff --git a/public/theme/src/components/ReCast/Login.vue b/public/theme/src/components/ReCast/Login.vue index b3b337f..d9d34c2 100644 --- a/public/theme/src/components/ReCast/Login.vue +++ b/public/theme/src/components/ReCast/Login.vue @@ -37,8 +37,8 @@ data() { return { login: { - _username: 'Shyim', - _password: '1', + _username: '', + _password: '', }, rememberMe: false, authFailed: false diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php new file mode 100644 index 0000000..084ab66 --- /dev/null +++ b/src/Command/CreateUserCommand.php @@ -0,0 +1,71 @@ + + */ +class CreateUserCommand extends Command implements ContainerAwareInterface +{ + use ContainerAwareTrait; + + /** + * @var UserPasswordEncoderInterface + */ + private $passwordEncoder; + + /** + * CreateUserCommand constructor. + * @param null|string $name + * @param UserPasswordEncoderInterface $passwordEncoder + * @author Soner Sayakci + */ + public function __construct(?string $name = null, UserPasswordEncoderInterface $passwordEncoder) + { + parent::__construct($name); + $this->passwordEncoder = $passwordEncoder; + } + + /** + * @author Soner Sayakci + */ + public function configure() + { + $this + ->setName('recast:create:user') + ->setDescription('Creates a new user'); + } + + public function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + + $username = $io->ask('What should be the username?'); + $email = $io->ask('What should be the email?'); + $password = $io->askHidden('What should be the password?'); + + $user = new User(); + $encoded = $this->passwordEncoder->encodePassword($user, $password); + $user->setUsername($username); + $user->setPassword($encoded); + $user->setEmail($email); + + $manager = $this->container->get('doctrine.orm.default_entity_manager'); + $manager->persist($user); + $manager->flush(); + + $io->success('User has been successfully created'); + } +} \ No newline at end of file