mirror of
https://github.com/resources-manager/resources-manager-webui.git
synced 2024-11-21 15:39:20 +01:00
wip
This commit is contained in:
parent
cc20f83fc2
commit
8a0e27a287
|
@ -6,3 +6,12 @@ login:
|
|||
path: /login
|
||||
controller: App\Controller\SecurityController::login
|
||||
methods: GET|POST
|
||||
|
||||
register:
|
||||
path: /register
|
||||
controller: App\Controller\SecurityController::show_register_form
|
||||
methods: GET|POST
|
||||
register:
|
||||
path: /register
|
||||
controller: App\Controller\SecurityController::register
|
||||
methods: POST
|
|
@ -4,6 +4,11 @@ namespace App\Controller;
|
|||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use App\Entity\User;
|
||||
|
@ -31,4 +36,35 @@ class SecurityController extends AbstractController
|
|||
{
|
||||
throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/register", name="register")
|
||||
*/
|
||||
|
||||
public function show_register_form()
|
||||
{
|
||||
return $this->render('security/register.html.twig', [
|
||||
'form' => $this->get_registerform()->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
private function get_registerform()
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->add('email', EmailType::class)
|
||||
->add('password', PasswordType::class, [])
|
||||
->add('display_name', TextType::class,[])
|
||||
->add('save', SubmitType::class)
|
||||
->getForm();
|
||||
|
||||
}
|
||||
|
||||
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder)
|
||||
{
|
||||
$form = $this->get_registerform();
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,16 @@ class User implements UserInterface
|
|||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $display_name;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -110,4 +120,28 @@ class User implements UserInterface
|
|||
// If you store any temporary, sensitive data on the user, clear it here
|
||||
// $this->plainPassword = null;
|
||||
}
|
||||
|
||||
public function getActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): self
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisplayName(): ?string
|
||||
{
|
||||
return $this->display_name;
|
||||
}
|
||||
|
||||
public function setDisplayName(string $display_name): self
|
||||
{
|
||||
$this->display_name = $display_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
35
src/Migrations/Version20191226142335.php
Normal file
35
src/Migrations/Version20191226142335.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20191226142335 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE user ADD active TINYINT(1) NOT NULL, ADD display_name VARCHAR(255) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE user DROP active, DROP display_name');
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<header>{% block header %}<h1>Resources booking manager</h1>{% endblock %}</header>
|
||||
{% block body %}{% endblock %}
|
||||
{% block javascripts %}{% endblock %}
|
||||
</body>
|
||||
|
|
8
templates/security/register.html.twig
Normal file
8
templates/security/register.html.twig
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
{% block title %}Register{% endblock %}
|
||||
{% block header %}<h1>Register a new user</h1>{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
{{ form(form) }}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user