Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show class name of security token in WDT
  • Loading branch information
lmcd committed Dec 20, 2012
1 parent 8df9b7a commit 15c52f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -39,20 +39,25 @@ public function collect(Request $request, Response $response, \Exception $except
$this->data = array(
'enabled' => false,
'authenticated' => false,
'token_class' => null,
'user' => '',
'roles' => array(),
);
} elseif (null === $token = $this->context->getToken()) {
$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()),
);
Expand Down Expand Up @@ -99,6 +104,16 @@ public function isAuthenticated()
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}
*/
Expand Down
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 15c52f5

Please sign in to comment.