[DX] Added a logout link in the security panel of the web debug toolbar

This commit is contained in:
Javier Eguiluz 2015-04-16 17:43:29 +02:00 committed by Fabien Potencier
parent 317d30b6ef
commit 192523aeab
2 changed files with 19 additions and 0 deletions

View File

@ -50,6 +50,7 @@ class SecurityDataCollector extends DataCollector
'enabled' => false,
'authenticated' => false,
'token_class' => null,
'provider_key' => null,
'user' => '',
'roles' => array(),
'inherited_roles' => array(),
@ -60,6 +61,7 @@ class SecurityDataCollector extends DataCollector
'enabled' => true,
'authenticated' => false,
'token_class' => null,
'provider_key' => null,
'user' => '',
'roles' => array(),
'inherited_roles' => array(),
@ -80,6 +82,7 @@ class SecurityDataCollector extends DataCollector
'enabled' => true,
'authenticated' => $token->isAuthenticated(),
'token_class' => get_class($token),
'provider_key' => method_exists($token, 'getProviderKey') ? $token->getProviderKey() : null,
'user' => $token->getUsername(),
'roles' => array_map(function (RoleInterface $role) { return $role->getRole();}, $assignedRoles),
'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles),
@ -159,6 +162,16 @@ class SecurityDataCollector extends DataCollector
return $this->data['token_class'];
}
/**
* Get the provider key (i.e. the name of the active firewall).
*
* @return string The provider key
*/
public function getProviderKey()
{
return $this->data['provider_key'];
}
/**
* {@inheritdoc}
*/

View File

@ -31,6 +31,12 @@
<span>{{ collector.tokenClass|abbr_class }}</span>
</div>
{% endif %}
{% if collector.providerKey %}
<div class="sf-toolbar-info-piece">
<b>Actions</b>
<span><a href="{{ logout_path(collector.providerKey) }}">Logout</a></span>
</div>
{% endif %}
{% elseif collector.enabled %}
<div class="sf-toolbar-info-piece">
<span>You are not authenticated.</span>