Implemented FOS bundle

This commit is contained in:
Kevin Frantz 2018-09-13 02:24:25 +02:00
parent 777b4aee61
commit 629ed13c51
46 changed files with 451 additions and 202 deletions

View File

@ -21,4 +21,8 @@ APP_SECRET=997425e20bc2144c301a312511101613
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost" # Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
###> friendsofsymfony/user-bundle ###
MAILER_SENDER=test@test.de
MAILER_USER=user
###< friendsofsymfony/user-bundle ###

View File

@ -5,6 +5,7 @@
"php": "^7.1.3", "php": "^7.1.3",
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*", "ext-iconv": "*",
"friendsofsymfony/user-bundle": "~2.1",
"knplabs/knp-menu-bundle": "^2.0", "knplabs/knp-menu-bundle": "^2.0",
"sensio/framework-extra-bundle": "^5.1", "sensio/framework-extra-bundle": "^5.1",
"symfony/asset": "*", "symfony/asset": "*",

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "46e513d742140ba387e272208c8a9dc9", "content-hash": "49bb78c3c5e9cebe665f0e40f98e14b8",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -1281,6 +1281,82 @@
], ],
"time": "2016-10-17T18:31:11+00:00" "time": "2016-10-17T18:31:11+00:00"
}, },
{
"name": "friendsofsymfony/user-bundle",
"version": "v2.1.2",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
"reference": "1049935edd24ec305cc6cfde1875372fa9600446"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/1049935edd24ec305cc6cfde1875372fa9600446",
"reference": "1049935edd24ec305cc6cfde1875372fa9600446",
"shasum": ""
},
"require": {
"paragonie/random_compat": "^1 || ^2",
"php": "^5.5.9 || ^7.0",
"symfony/form": "^2.8 || ^3.0 || ^4.0",
"symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/templating": "^2.8 || ^3.0 || ^4.0",
"symfony/twig-bundle": "^2.8 || ^3.0 || ^4.0",
"symfony/validator": "^2.8 || ^3.0 || ^4.0",
"twig/twig": "^1.28 || ^2.0"
},
"conflict": {
"doctrine/doctrine-bundle": "<1.3",
"symfony/doctrine-bridge": "<2.7"
},
"require-dev": {
"doctrine/doctrine-bundle": "^1.3",
"friendsofphp/php-cs-fixer": "^2.2",
"phpunit/phpunit": "^4.8.35|^5.7.11|^6.5",
"swiftmailer/swiftmailer": "^4.3 || ^5.0 || ^6.0",
"symfony/console": "^2.8 || ^3.0 || ^4.0",
"symfony/phpunit-bridge": "^2.8 || ^3.0 || ^4.0",
"symfony/yaml": "^2.8 || ^3.0 || ^4.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
},
"autoload": {
"psr-4": {
"FOS\\UserBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
},
{
"name": "FriendsOfSymfony Community",
"homepage": "https://github.com/friendsofsymfony/FOSUserBundle/contributors"
},
{
"name": "Thibault Duplessis"
}
],
"description": "Symfony FOSUserBundle",
"homepage": "http://friendsofsymfony.github.com",
"keywords": [
"User management"
],
"time": "2018-03-08T08:59:27+00:00"
},
{ {
"name": "jdorn/sql-formatter", "name": "jdorn/sql-formatter",
"version": "v1.2.17", "version": "v1.2.17",
@ -4292,6 +4368,62 @@
"homepage": "http://symfony.com", "homepage": "http://symfony.com",
"time": "2018-08-29T08:49:17+00:00" "time": "2018-08-29T08:49:17+00:00"
}, },
{
"name": "symfony/templating",
"version": "v4.1.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/templating.git",
"reference": "411b8c324ee3e8b36e71d938e8d043d6e16582d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/templating/zipball/411b8c324ee3e8b36e71d938e8d043d6e16582d2",
"reference": "411b8c324ee3e8b36e71d938e8d043d6e16582d2",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"require-dev": {
"psr/log": "~1.0"
},
"suggest": {
"psr/log-implementation": "For using debug logging in loaders"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Templating\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Templating Component",
"homepage": "https://symfony.com",
"time": "2018-07-26T11:24:31+00:00"
},
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v4.1.4", "version": "v4.1.4",

View File

@ -15,4 +15,5 @@ return [
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true], Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
FOS\UserBundle\FOSUserBundle::class => ['all' => true],
]; ];

View File

@ -0,0 +1,7 @@
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: App\Entity\User
from_email:
address: "%env(MAILER_SENDER)%"
sender_name: "%env(MAILER_USER)%"

View File

@ -28,3 +28,5 @@ framework:
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu #app: cache.adapter.apcu
templating:
engines: ['twig', 'php']

View File

@ -1,13 +1,13 @@
security: security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
encoders: encoders:
App\Entity\User: FOS\UserBundle\Model\UserInterface: bcrypt
algorithm: bcrypt
providers: providers:
our_db_provider: fos_userbundle:
entity: id: fos_user.user_provider.username
class: App\Entity\User role_hierarchy:
property: username ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
hide_user_not_found: false hide_user_not_found: false
firewalls: firewalls:
dev: dev:
@ -16,21 +16,18 @@ security:
main: main:
anonymous: true anonymous: true
form_login: form_login:
login_path: login provider: fos_userbundle
check_path: login csrf_token_generator: security.csrf.token_manager
logout: logout: true
path: /logout
target: /
# activate different ways to authenticate # activate different ways to authenticate
# http_basic: true # http_basic: true
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
# form_login: true
# https://symfony.com/doc/current/security/form_login_setup.html
# Easy way to control access for large sections of your site # Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used # Note: Only the *first* access control that matches will be used
access_control: access_control:
# - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
# - { path: ^/profile, roles: ROLE_USER } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }

View File

@ -1,2 +1,4 @@
logout: logout:
path: /logout path: /logout
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"

View File

@ -1,61 +0,0 @@
<?php
namespace App\Controller;
use App\Form\UserType;
use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Form\FormInterface;
class RegistrationController extends AbstractController
{
/**
*
* @var User
*/
private $user;
/**
*
* @Route("/register", name="user_register")
*/
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder,TranslatorInterface $translator): Response
{
$this->user = new User();
$form = $this->createForm(UserType::class, $this->user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->encodePassword($passwordEncoder);
$this->saveUser($translator);
return $this->redirectToRoute('login');
}
return $this->render("user/register.html.twig", array(
'form' => $form->createView()
));
}
public function encodePassword(UserPasswordEncoderInterface $passwordEncoder): void
{
$password = $passwordEncoder->encodePassword($this->user, $this->user->getPlainPassword());
$this->user->setPassword($password);
}
private function saveUser(TranslatorInterface $translator): void
{
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($this->user);
try {
$entityManager->flush();
$this->addFlash('success', $translator->trans('User "%username%" created!',['%username%'=>$this->user->getUsername()]));
} catch (\Exception $exception) {
$this->addFlash('danger', $translator->trans('User "%username%" could not be created!',['%username%'=>$this->user->getUsername()]));
}
}
}

View File

@ -1,37 +0,0 @@
<?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;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
* @author kevinfrantz
*
*/
class SecurityController extends AbstractController
{
/**
*
* @Route("/login", name="login")
*/
public function login(AuthenticationUtils $authenticationUtils,TranslatorInterface $translator): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
if ($error) {
$this->addFlash('danger', $translator->trans($error->getMessageKey(),$error->getMessageData(),'security'));
}else{
$lastUsername = $authenticationUtils->getLastUsername();
if($lastUsername){
$this->addFlash('success', $translator->trans('User %user% loged in.',['%user%'=>$lastUsername]));
}
}
return $this->render("user/login.html.twig",[
'last_username'=>$authenticationUtils->getLastUsername(),
]);
}
}

View File

@ -1,6 +1,8 @@
<?php <?php
namespace App\Entity\Attribut; namespace App\Entity\Attribut;
use Doctrine\ORM\Mapping as ORM;
/** /**
* *
* @author kevinfrantz * @author kevinfrantz
@ -8,7 +10,7 @@ namespace App\Entity\Attribut;
*/ */
trait IdAttribut { trait IdAttribut {
/** /**
* @ORM\Id * @ORM\Id()
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO") * @ORM\Column(type="integer")(strategy="AUTO")
*/ */

View File

@ -2,9 +2,8 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\UsernameAttribut; use FOS\UserBundle\Model\User as BaseUser;
use App\Entity\Attribut\PasswordAttribut; use App\Entity\Attribut\NodeAttribut;
use App\Entity\Attribut\PlainPasswordAttribute;
/** /**
* *
@ -12,51 +11,39 @@ use App\Entity\Attribut\PlainPasswordAttribute;
* @ORM\Table(name="source_user") * @ORM\Table(name="source_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository") * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/ */
class User extends AbstractSource implements UserInterface class User extends BaseUser implements SourceInterface
{ {
use UsernameAttribut,PasswordAttribut,PlainPasswordAttribute; use NodeAttribut;
/** /**
* @ORM\Column(name="is_active", type="boolean") * @ORM\Column(name="is_active", type="boolean")
*/ */
private $isActive; private $isActive;
/**
* @ORM\Id()
* @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO")
*/
protected $id;
public function setId(int $id): void
{
$this->id = $id;
}
public function getId(): int
{
return $this->id;
}
public function __construct() public function __construct()
{ {
parent::__construct ();
/**
* @todo Remove this later
* @var \App\Entity\User $isActive
*/
$this->isActive = true; $this->isActive = true;
} }
public function getSalt()
{
return null;
}
public function getRoles()
{
return array('ROLE_USER');
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
) = unserialize($serialized, array('allowed_classes' => false));
}
} }

View File

@ -1,14 +0,0 @@
<?php
namespace App\Entity;
use Symfony\Component\Security\Core\User\UserInterface as SymfonyUserInterface;
/**
*
* @author kevinfrantz
*
*/
interface UserInterface extends SymfonyUserInterface, \Serializable
{
}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/ChangePassword/change_password_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_change_password'), 'attr': { 'class': 'fos_user_change_password' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'change_password.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/edit_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_group_edit', {'groupName': group_name}), 'attr': { 'class': 'fos_user_group_edit' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'group.edit.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/list_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,7 @@
<div class="fos_user_group_list">
<ul>
{% for group in groups %}
<li><a href="{{ path('fos_user_group_show', {'groupName': group.getName()} ) }}">{{ group.getName() }}</a></li>
{% endfor %}
</ul>
</div>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/new_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_group_new'), 'attr': { 'class': 'fos_user_group_new' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'group.new.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/show_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,5 @@
{% trans_default_domain 'FOSUserBundle' %}
<div class="fos_user_group_show">
<p>{{ 'group.show.name'|trans }}: {{ group.getName() }}</p>
</div>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Profile/edit_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_profile_edit'), 'attr': { 'class': 'fos_user_profile_edit' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'profile.edit.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Profile/show_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,6 @@
{% trans_default_domain 'FOSUserBundle' %}
<div class="fos_user_user_show">
<p>{{ 'profile.show.username'|trans }}: {{ user.username }}</p>
<p>{{ 'profile.show.email'|trans }}: {{ user.email }}</p>
</div>

View File

@ -0,0 +1,7 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>{{ 'registration.check_email'|trans({'%email%': user.email}) }}</p>
{% endblock fos_user_content %}

View File

@ -0,0 +1,10 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>{{ 'registration.confirmed'|trans({'%username%': user.username}) }}</p>
{% if targetUrl %}
<p><a href="{{ targetUrl }}">{{ 'registration.back'|trans }}</a></p>
{% endif %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,13 @@
{% trans_default_domain 'FOSUserBundle' %}
{% block subject %}
{%- autoescape false -%}
{{ 'registration.email.subject'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{%- endautoescape -%}
{% endblock %}
{% block body_text %}
{% autoescape false %}
{{ 'registration.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_html %}{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Registration/register_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,9 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>
{{ 'resetting.check_email'|trans({'%tokenLifetime%': tokenLifetime})|nl2br }}
</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% trans_default_domain 'FOSUserBundle' %}
{% block subject %}
{%- autoescape false -%}
{{ 'resetting.email.subject'|trans({'%username%': user.username}) }}
{%- endautoescape -%}
{% endblock %}
{% block body_text %}
{% autoescape false %}
{{ 'resetting.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_html %}{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Resetting/request_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,11 @@
{% trans_default_domain 'FOSUserBundle' %}
<form action="{{ path('fos_user_resetting_send_email') }}" method="POST" class="fos_user_resetting_request">
<div>
<label for="username">{{ 'resetting.request.username'|trans }}</label>
<input type="text" id="username" name="username" required="required" />
</div>
<div>
<input type="submit" value="{{ 'resetting.request.submit'|trans }}" />
</div>
</form>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Resetting/reset_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_resetting_reset', {'token': token}), 'attr': { 'class': 'fos_user_resetting_reset' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'resetting.reset.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,10 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block title %}
{% trans %}login{% endtrans %}
{% endblock %}
{% block content %}
<h1>
{% trans %}login{% endtrans %}
</h1>
{{ include('@FOSUser/Security/login_content.html.twig') }}
{% endblock %}

View File

@ -0,0 +1,27 @@
{% trans_default_domain 'FOSUserBundle' %}
{% if error %}
{% include "frames/structure/message/message.html.twig" with {'message':error.messageKey|trans(error.messageData, 'security'),'label':'danger'} %}
{% endif %}
<form action="{{ path("fos_user_security_check") }}" method="post">
{% if csrf_token %}
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
{% endif %}
<div class="form-group">
<label for="username">{{ 'security.login.username'|trans }}</label> <input
type="text" id="username" name="_username"
value="{{ last_username }}" required="required" class="form-control"
autocomplete="username" />
</div>
<div class="form-group">
<label for="password">{{ 'security.login.password'|trans }}</label> <input
type="password" id="password" name="_password" class="form-control" required="required"
autocomplete="current-password" />
</div>
<div class="form-group">
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
</div>
<input type="submit" id="_submit" name="_submit"
value="{{ 'security.login.submit'|trans }}" class="btn btn-primary"/>
</form>

View File

@ -0,0 +1,28 @@
{% extends "frames/default.html.twig" %}
{% block content %}
<div>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }}
| <a href="{{ path('fos_user_security_logout') }}"> {{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
</a>
{% else %}
<a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
{% endif %}
</div>
{% if app.request.hasPreviousSession %}
{% for type, messages in app.session.flashbag.all() %}
{% for message in messages %}
<div class="flash-{{ type }}">
{{ message }}
</div>
{% endfor %}
{% endfor %}
{% endif %}
<div>
{% block fos_user_content %}
{% endblock fos_user_content %}
</div>
{% endblock content %}

View File

@ -63,7 +63,7 @@ class UserMenuSubscriber implements EventSubscriberInterface
]); ]);
} else { } else {
$dropdown->addChild('login', [ $dropdown->addChild('login', [
'route' => 'login', 'route' => 'fos_user_security_login',
'attributes' => [ 'attributes' => [
'divider_append' => true, 'divider_append' => true,
'icon' => 'fas fa-sign-in-alt' 'icon' => 'fas fa-sign-in-alt'
@ -71,7 +71,7 @@ class UserMenuSubscriber implements EventSubscriberInterface
]); ]);
} }
$dropdown->addChild('register', [ $dropdown->addChild('register', [
'route' => 'user_register', 'route' => 'fos_user_registration_register',
'attributes' => [ 'attributes' => [
'icon' => 'fas fa-file-signature' 'icon' => 'fas fa-file-signature'
] ]

View File

@ -80,6 +80,9 @@
"fig/link-util": { "fig/link-util": {
"version": "1.0.0" "version": "1.0.0"
}, },
"friendsofsymfony/user-bundle": {
"version": "v2.1.2"
},
"jdorn/sql-formatter": { "jdorn/sql-formatter": {
"version": "v1.2.17" "version": "v1.2.17"
}, },
@ -395,6 +398,9 @@
"ref": "3db029c03e452b4a23f7fc45cec7c922c2247eb8" "ref": "3db029c03e452b4a23f7fc45cec7c922c2247eb8"
} }
}, },
"symfony/templating": {
"version": "v4.1.4"
},
"symfony/test-pack": { "symfony/test-pack": {
"version": "v1.0.2" "version": "v1.0.2"
}, },

View File

@ -1,8 +1,5 @@
{% set icons = {'success':'fas fa-check-circle','danger':'fas fa-times','warning':'fas fa-exclamation-triangle','info':'fas fa-info'} %}
{% for label,messages in app.flashes %} {% for label,messages in app.flashes %}
{% for message in messages %} {% for message in messages %}
<div class="alert alert-{{ label }}"> {% include "frames/structure/message/message.html.twig" with {'message':message,'label':label} %}
<i class="{{ icons[label] }}"></i> {{ message }}
</div>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}

View File

@ -0,0 +1,4 @@
{% set icons = {'success':'fas fa-check-circle','danger':'fas fa-times','warning':'fas fa-exclamation-triangle','info':'fas fa-info'} %}
<div class="alert alert-{{ label }}">
<i class="{{ icons[label] }}"></i> {{ message }}
</div>

View File

@ -1,25 +0,0 @@
{% extends "frames/default.html.twig" %}
{% block title %}
{% trans %}login{% endtrans %}
{% endblock %}
{% block content %}
<h1>
{% trans %}login{% endtrans %}
</h1>
<form action={{ path('login') }} method="post">
<div class="form-group">
<label for="username">{% trans %}Username{% endtrans %}</label> <input
type="username" name="_username" class="form-control" id="username"
aria-describedby="usernameHelp"
placeholder="{% trans %}Enter username{% endtrans %}'">
</div>
<div class="form-group">
<label for="password">{% trans %}Password{% endtrans %}</label> <input
type="password" name="_password" class="form-control" id="password"
placeholder="{% trans %}Password{% endtrans %}">
</div>
<button type="submit" class="btn btn-primary">
{% trans %}Submit{% endtrans %}
</button>
</form>
{% endblock %}