content.about
For more information, check out the Symfony doc.
Click on this button to show the source code of the Controller and template used to render this page.
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_username' => "",
// 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>
<button type="submit" class="btn btn-default">
<i class="fa fa-sign-in" aria-hidden="true"></i> {{ 'action.register'|trans }}
</button>
</fieldset>
</form>
</div>
</div>
</div>
{% endblock %}
{% block sidebar %}
{{ parent() }}
{{ show_source_code(_self) }}
{% endblock %}