mirror of
https://github.com/r4sas/recastin-panel
synced 2025-03-13 05:41:20 +00:00
Added command to create user
This commit is contained in:
parent
0bc6509748
commit
6d02a4a6d1
3
.gitignore
vendored
3
.gitignore
vendored
@ -23,4 +23,5 @@ yarn-error.log
|
||||
###< symfony/web-server-bundle ###
|
||||
|
||||
.idea
|
||||
/config/jwt
|
||||
/config/jwt
|
||||
/public/static
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -37,8 +37,8 @@
|
||||
data() {
|
||||
return {
|
||||
login: {
|
||||
_username: 'Shyim',
|
||||
_password: '1',
|
||||
_username: '',
|
||||
_password: '',
|
||||
},
|
||||
rememberMe: false,
|
||||
authFailed: false
|
||||
|
71
src/Command/CreateUserCommand.php
Normal file
71
src/Command/CreateUserCommand.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Class CreateUserCommand
|
||||
* @author Soner Sayakci <shyim@posteo.de>
|
||||
*/
|
||||
class CreateUserCommand extends Command implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* @var UserPasswordEncoderInterface
|
||||
*/
|
||||
private $passwordEncoder;
|
||||
|
||||
/**
|
||||
* CreateUserCommand constructor.
|
||||
* @param null|string $name
|
||||
* @param UserPasswordEncoderInterface $passwordEncoder
|
||||
* @author Soner Sayakci <shyim@posteo.de>
|
||||
*/
|
||||
public function __construct(?string $name = null, UserPasswordEncoderInterface $passwordEncoder)
|
||||
{
|
||||
parent::__construct($name);
|
||||
$this->passwordEncoder = $passwordEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Soner Sayakci <shyim@posteo.de>
|
||||
*/
|
||||
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');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user