Mam taki kod, mimo że jestem zalogowany to oba if się wykonują.
{% extends "base.html.twig" %}
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
{% block alerts %}
<div class="alert alert-danger">
<h4 class="alert-heading">The login form can not be displayed</h4>
You are already logged in as <b> {{ app.user.username }} </b>!<br>
Return to the
<a class="link-custom alert-link" style="color: #491217;" onmouseover="this.style.textDecoration='underline';"
onmouseout="this.style.textDecoration='none';" onclick="window.history.go(-1); return false;">previous page</a>
or go to the <a class="alert-link" href="/">homepage</a>.
<hr>
If you want to log in, you have to <a class="alert-link" href="/logout">logout</a> first.
</div>
{% endblock %}
{% else %}
{% block body %}
{% if error %}
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
<form action="{{ path('login') }}" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" />
<label for="password">Password:</label>
<input type="password" id="password" name="_password" />
{#
If you want to control the URL the user
is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<button type="submit">login</button>
</form>
{% endblock %}
{% endif %}