content.about
Voor meer informatie, bekijk de Symfony documentatie.
Klik op deze knop om de broncode te bekijken van de Controller en template, die gebruikt zijn bij het weergeven van deze pagina.
public function login(Request $request, AuthenticationUtils $helper): Response
{
// if user is already logged in, don't display the login page again
if ($this->getUser()) {
return $this->redirectToRoute('blog_index');
}
// this statement solves an edge-case: if you change the locale in the login
// page, after a successful login you are redirected to a page in the previous
// locale. This code regenerates the referrer URL whenever the login page is
// browsed, to ensure that its locale is always the current one.
$this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index'));
return $this->render('security/login.html.twig', [
// last username entered by the user (if any)
// 'last_username' => $helper->getLastUsername(),
// last authentication error (if any)
'error' => $helper->getLastAuthenticationError(),
]);
}
{% extends 'base.html.twig' %}
{% block body_id 'login' %}
{% block javascripts %}
{{ parent() }}
{{ encore_entry_script_tags('login') }}
{% endblock %}
{% block main %}
{% if error %}
<div class="alert alert-danger">
{{ error.messageKey|trans(error.messageData, 'security') }}
</div>
{% endif %}
<div class="row">
<div class="col-sm-9">
<div class="well">
<form action="{{ path('security_login') }}" method="post">
<fieldset>
<legend><i class="fa fa-lock" aria-hidden="true"></i> {{ 'title.login'|trans }}</legend>
<div class="form-group">
<label for="username">{{ 'label.username'|trans }}</label>
<input type="text" id="username" name="_username" value="{#{{ last_username }}#}" class="form-control"/>
</div>
<div class="form-group">
<label for="password">{{ 'label.password'|trans }}</label>
<input type="password" id="password" name="_password" class="form-control" />
</div>
<input type="hidden" name="_target_path" value="{{ app.request.get('redirect_to') }}"/>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
<button type="submit" class="btn btn-primary">
<i class="fa fa-sign-in" aria-hidden="true"></i> {{ 'action.sign_in'|trans }}
</button>
</fieldset>
</form>
</div>
</div>
{#
<div id="login-help" class="col-sm-7">
<h3>
<i class="hidden-xs fa fa-long-arrow-left" aria-hidden="true"></i>
{{ 'help.login_users'|trans }}
</h3>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th scope="col">{{ 'label.username'|trans }}</th>
<th scope="col">{{ 'label.password'|trans }}</th>
<th scope="col">{{ 'label.role'|trans }}</th>
</tr>
</thead>
<tbody>
<tr>
<td>john_user</td>
<td>kitten</td>
<td><code>ROLE_USER</code> ({{ 'help.role_user'|trans }})</td>
</tr>
<tr>
<td>jane_admin</td>
<td>kitten</td>
<td><code>ROLE_ADMIN</code> ({{ 'help.role_admin'|trans }})</td>
</tr>
</tbody>
</table>
<div id="login-users-help" class="panel panel-default">
<div class="panel-body">
<p>
<span class="label label-success">{{ 'note'|trans }}</span>
{{ 'help.reload_fixtures'|trans }}<br/>
<code class="console">$ php bin/console doctrine:fixtures:load</code>
</p>
<p>
<span class="label label-success">{{ 'tip'|trans }}</span>
{{ 'help.add_user'|trans }}<br/>
<code class="console">$ php bin/console app:add-user</code>
</p>
</div>
</div>
</div>
#}
</div>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{{ show_source_code(_self) }}
{% endblock %}