Show class name of security token in WDT
This commit is contained in:
parent
8df9b7a2de
commit
15c52f507e
@ -39,6 +39,7 @@ class SecurityDataCollector extends DataCollector
|
||||
$this->data = array(
|
||||
'enabled' => false,
|
||||
'authenticated' => false,
|
||||
'token_class' => null,
|
||||
'user' => '',
|
||||
'roles' => array(),
|
||||
);
|
||||
@ -46,13 +47,17 @@ class SecurityDataCollector extends DataCollector
|
||||
$this->data = array(
|
||||
'enabled' => true,
|
||||
'authenticated' => false,
|
||||
'token_class' => null,
|
||||
'user' => '',
|
||||
'roles' => array(),
|
||||
);
|
||||
} else {
|
||||
$class = explode('\\', get_class($token));
|
||||
|
||||
$this->data = array(
|
||||
'enabled' => true,
|
||||
'authenticated' => $token->isAuthenticated(),
|
||||
'token_class' => end($class),
|
||||
'user' => $token->getUsername(),
|
||||
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
|
||||
);
|
||||
@ -99,6 +104,16 @@ class SecurityDataCollector extends DataCollector
|
||||
return $this->data['authenticated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name of the security token (without namespace).
|
||||
*
|
||||
* @return String The token
|
||||
*/
|
||||
public function getTokenClass()
|
||||
{
|
||||
return $this->data['token_class'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -18,6 +18,12 @@
|
||||
<b>Authenticated</b>
|
||||
<span class="sf-toolbar-status sf-toolbar-status-{{ authentication_color_code }}">{{ authentication_color_text }}</span>
|
||||
</div>
|
||||
{% if collector.tokenClass != null %}
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<b>Token class</b>
|
||||
{{ collector.tokenClass }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elseif collector.enabled %}
|
||||
You are not authenticated.
|
||||
{% else %}
|
||||
@ -61,6 +67,12 @@
|
||||
<th>Roles</th>
|
||||
<td>{{ collector.roles|yaml_encode }}</td>
|
||||
</tr>
|
||||
{% if collector.tokenClass != null %}
|
||||
<tr>
|
||||
<th>Token class</th>
|
||||
<td>{{ collector.tokenClass }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% elseif collector.enabled %}
|
||||
<p>
|
||||
|
Reference in New Issue
Block a user