backports murph-skeleton

This commit is contained in:
Simon Vieille 2022-02-28 11:35:02 +01:00
parent 0b7dbc98d5
commit 581172e7b3
4 changed files with 54 additions and 23 deletions

View file

@ -229,21 +229,27 @@ tr.table-primary-light {
}
}
@media screen and (max-width: 1080px) {
.sidebar-sticky {
overflow-y: auto !important;
}
}
@media screen and (max-width: 770px) {
.body {
margin-left: 50px;
width: calc(100vw - 50px);
}
.sidebar-sticky {
width: 50px;
max-width: 100% !important;
}
.sidebar {
width: 50px;
max-width: 100% !important;
.sidebar-sticky {
width: 50px;
max-width: 100% !important;
}
.nav {
padding-left: 0;
}

View file

@ -7,10 +7,12 @@ use App\Core\Manager\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
class UserCreateCommand extends Command
{
@ -18,11 +20,16 @@ class UserCreateCommand extends Command
protected static $defaultDescription = 'Creates a user';
protected UserFactory $userFactory;
protected EntityManager $entityManager;
protected TokenGeneratorInterface $tokenGenerator;
public function __construct(UserFactory $userFactory, EntityManager $entityManager)
{
public function __construct(
UserFactory $userFactory,
EntityManager $entityManager,
TokenGeneratorInterface $tokenGenerator
) {
$this->userFactory = $userFactory;
$this->entityManager = $entityManager;
$this->tokenGenerator = $tokenGenerator;
parent::__construct();
}
@ -32,6 +39,8 @@ class UserCreateCommand extends Command
$this
->setDescription(self::$defaultDescription)
->addArgument('email', InputArgument::OPTIONAL, 'E-mail')
->addOption('is-admin', null, InputOption::VALUE_NONE, 'Add the admin role')
->addOption('is-writer', null, InputOption::VALUE_NONE, 'Add the write role')
;
}
@ -43,9 +52,7 @@ class UserCreateCommand extends Command
$emailQuestion = new Question('E-mail: ');
$emailQuestion->setValidator(function ($value) {
if (empty($value)) {
throw new \RuntimeException(
'The email must not be empty.'
);
throw new \RuntimeException('The email must not be empty.');
}
return $value;
@ -53,8 +60,17 @@ class UserCreateCommand extends Command
$passwordQuestion = new Question('Password (leave empty to generate a random password): ');
$passwordQuestion->setHidden(true);
$isAdminQuestion = new ConfirmationQuestion('Is admin? [y/n] ', false);
$isWriterQuestion = new ConfirmationQuestion('Is writer? [y/n] ', false);
$isAdminDefault = $input->getOption('is-admin');
$isWriterDefault = $input->getOption('is-writer');
$isAdminQuestionLabel = sprintf('Administrator [%s] ', $isAdminDefault ? 'Y/n' : 'y/N');
$isWriterQuestionLabel = sprintf('Writer [%s] ', $isWriterDefault ? 'Y/n' : 'y/N');
$isAdminQuestion = new ConfirmationQuestion($isAdminQuestionLabel, $isAdminDefault);
$isWriterQuestion = new ConfirmationQuestion($isWriterQuestionLabel, $isWriterDefault);
$io->section('Authentication');
$email = $input->getArgument('email');
@ -63,6 +79,18 @@ class UserCreateCommand extends Command
}
$password = $helper->ask($input, $output, $passwordQuestion);
$showPassword = empty($password);
if ($showPassword) {
$password = mb_substr($this->tokenGenerator->generateToken(), 0, 18);
$io->info(sprintf('Password: %s', $password));
} else {
$io->newLine();
}
$io->section('Roles');
$isAdmin = $helper->ask($input, $output, $isAdminQuestion);
$isWriter = $helper->ask($input, $output, $isWriterQuestion);
@ -72,6 +100,7 @@ class UserCreateCommand extends Command
$this->entityManager->create($user);
$io->newLine();
$io->success('User created!');
return Command::SUCCESS;

View file

@ -16,9 +16,8 @@ class UserFactory implements FactoryInterface
protected TokenGeneratorInterface $tokenGenerator;
protected UserPasswordEncoderInterface $encoder;
public function __construct(TokenGeneratorInterface $tokenGenerator, UserPasswordEncoderInterface $encoder)
public function __construct(UserPasswordEncoderInterface $encoder)
{
$this->tokenGenerator = $tokenGenerator;
$this->encoder = $encoder;
}
@ -26,14 +25,13 @@ class UserFactory implements FactoryInterface
{
$entity = new User();
if (!empty($email)) {
if (null !== $email) {
$entity->setEmail($email);
}
$entity->setPassword($this->encoder->encodePassword(
$entity,
!empty($password) ? $password : $this->tokenGenerator->generateToken()
));
if (null !== $email) {
$entity->setPassword($this->encoder->encodePassword($entity, $password));
}
return $entity;
}

View file

@ -125,7 +125,7 @@
</div>
<div class="col-6">
<div class="float-right">
<div class="d-none d-md-block">
<div class="d-none d-lg-block">
{% if node.page %}
<a href="{{ path('admin_site_page_edit', {entity: node.page.id}) }}" class="btn btn-sm btn-warning text-white mr-1 mb-1">
<span class="fa fa-file-alt"></span>
@ -141,10 +141,8 @@
<button form="form-node-visibility-{{ node.id }}" class="btn btn-sm btn-light border-dark mr-1 mb-1">
{% if node.isVisible %}
<span class="fa fa-eye"></span>
{{ 'Visible'|trans }}
{% else %}
<span class="fa fa-eye-slash"></span>
{{ 'Hidden'|trans }}
{% endif %}
</button>
@ -166,7 +164,7 @@
<span class="fa fa-trash"></span>
</button>
</div>
<div class="d-block d-md-none text-left">
<div class="d-block d-lg-none text-left">
<button type="button" class="btn btn-sm dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ 'Actions'|trans }}
</button>