mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
In between commit implementation securitycontroller
This commit is contained in:
parent
7a859080e5
commit
0c689194a2
@ -8,13 +8,16 @@ security:
|
|||||||
entity:
|
entity:
|
||||||
class: App\Entity\User
|
class: App\Entity\User
|
||||||
property: username
|
property: username
|
||||||
in_memory: { memory: ~ }
|
#in_memory: { memory: ~ }
|
||||||
firewalls:
|
firewalls:
|
||||||
dev:
|
dev:
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
security: false
|
security: false
|
||||||
main:
|
main:
|
||||||
anonymous: true
|
anonymous: true
|
||||||
|
form_login:
|
||||||
|
login_path: login
|
||||||
|
check_path: login
|
||||||
|
|
||||||
# activate different ways to authenticate
|
# activate different ways to authenticate
|
||||||
|
|
||||||
|
31
application/src/Controller/SecurityController.php
Normal file
31
application/src/Controller/SecurityController.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SecurityController extends AbstractController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Route("/login", name="login")
|
||||||
|
*/
|
||||||
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||||
|
{
|
||||||
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
|
if ($error) {
|
||||||
|
$this->addFlash('notice', $error);
|
||||||
|
}
|
||||||
|
return $this->render("user/login.html.twig",[
|
||||||
|
'last_username'=>$authenticationUtils->getLastUsername(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ namespace App\Controller;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -12,7 +13,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
*/
|
*/
|
||||||
class UserController extends AbstractController implements UserControllerInterface
|
class UserController extends AbstractController implements UserControllerInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @Route("/user/logout", name="user_logout")
|
* @Route("/user/logout", name="user_logout")
|
||||||
*/
|
*/
|
||||||
public function logout(): Response
|
public function logout(): Response
|
||||||
@ -21,14 +24,7 @@ class UserController extends AbstractController implements UserControllerInterfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/user/login", name="user_login")
|
*
|
||||||
*/
|
|
||||||
public function login(): Response
|
|
||||||
{
|
|
||||||
return $this->render("user/login.html.twig");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/user/register", name="user_register")
|
* @Route("/user/register", name="user_register")
|
||||||
*/
|
*/
|
||||||
public function register(): Response
|
public function register(): Response
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -12,7 +13,5 @@ interface UserControllerInterface
|
|||||||
{
|
{
|
||||||
public function logout():Response;
|
public function logout():Response;
|
||||||
|
|
||||||
public function login():Response;
|
|
||||||
|
|
||||||
public function register():Response;
|
public function register():Response;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class UserMenuSubscriber implements EventSubscriberInterface
|
|||||||
$dropdown->addChild(
|
$dropdown->addChild(
|
||||||
'login',
|
'login',
|
||||||
[
|
[
|
||||||
'route' => 'user_login',
|
'route' => 'login',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'divider_append' => true,
|
'divider_append' => true,
|
||||||
'icon' => 'fas fa-sign-in-alt',
|
'icon' => 'fas fa-sign-in-alt',
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
{% extends "frames/default.html.twig" %}
|
{% extends "frames/default.html.twig" %}
|
||||||
{% block title %}
|
{% block title %}
|
||||||
login
|
{% trans %}login{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Login</h1>
|
<h1>
|
||||||
<form method='post'>
|
{% trans %}login{% endtrans %}
|
||||||
|
</h1>
|
||||||
|
<form method={{ path('login') }}>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">Email address</label> <input type="email"
|
<label for="username">{% trans %}Username{% endtrans %}</label> <input
|
||||||
name="email" class="form-control" id="email"
|
type="username" name="username" class="form-control" id="username"
|
||||||
aria-describedby="emailHelp" placeholder="Enter email">
|
aria-describedby="usernameHelp"
|
||||||
|
placeholder="{% trans %}Enter username{% endtrans %}'">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password</label> <input type="password"
|
<label for="password">{% trans %}Password{% endtrans %}</label> <input
|
||||||
name="password" class="form-control" id="password"
|
type="password" name="password" class="form-control" id="password"
|
||||||
placeholder="Password">
|
placeholder="{% trans %}Password{% endtrans %}">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">
|
||||||
|
{% trans %}Submit{% endtrans %}
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user