Skip to content

Commit

Permalink
Added the roles in the Security panel of the profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
stof authored and fabpot committed Jan 17, 2011
1 parent 8235f71 commit 105d591
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -18,4 +18,12 @@

{% block panel %}
<h2>Security</h2>
{% if collector.authenticated %}
<strong>{{ collector.user }}</strong><br />
<strong>Roles</strong>: {{ collector.roles|yaml_encode }}
{% elseif collector.enabled %}
<em>No token.</em>
{% else %}
<em>The security component is disabled.</em>
{% endif %}
{% endblock %}
Expand Up @@ -39,18 +39,21 @@ public function collect(Request $request, Response $response, \Exception $except
'enabled' => false,
'authenticated' => false,
'user' => '',
'roles' => array(),
);
} elseif (null === $token = $this->context->getToken()) {
$this->data = array(
'enabled' => true,
'authenticated' => false,
'user' => '',
'roles' => array(),
);
} else {
$this->data = array(
'enabled' => true,
'authenticated' => $token->isAuthenticated(),
'user' => (string) $token->getUser(),
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
);
}
}
Expand All @@ -75,6 +78,16 @@ public function getUser()
return $this->data['user'];
}

/**
* Gets the roles of the user.
*
* @return array The roles
*/
public function getRoles()
{
return $this->data['roles'];
}

/**
* Checks if the user is authenticated or not.
*
Expand Down

0 comments on commit 105d591

Please sign in to comment.