Compare commits
No commits in common. "cce91c421a95855e8fd7843966a13847f7196dad" and "5dd372f2a2bbea3d7fa1c2af3ee17a3b1c494c25" have entirely different histories.
cce91c421a
...
5dd372f2a2
@ -69,15 +69,7 @@ class ApiController extends Controller
|
|||||||
// Récupération UID
|
// Récupération UID
|
||||||
$username = \phpCAS::getUser();
|
$username = \phpCAS::getUser();
|
||||||
$attributes = \phpCAS::getAttributes();
|
$attributes = \phpCAS::getAttributes();
|
||||||
if(isset($attributes[$this->getParameter('user_attr_cas_username')]))
|
|
||||||
$login = $attributes[$this->getParameter('user_attr_cas_username')];
|
|
||||||
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$login]);
|
|
||||||
if(!$user) {
|
|
||||||
$output["error"]="user does not exist";
|
|
||||||
return new Response(json_encode($output), 400);
|
|
||||||
}
|
|
||||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
|
||||||
if (in_array("ROLE_ADMIN",$roles)) {
|
|
||||||
return $this->render('CadolesEdispatcherBundle:Test:test.html.twig',[
|
return $this->render('CadolesEdispatcherBundle:Test:test.html.twig',[
|
||||||
'useheader' => true,
|
'useheader' => true,
|
||||||
'usemenu' => false,
|
'usemenu' => false,
|
||||||
@ -87,10 +79,6 @@ class ApiController extends Controller
|
|||||||
'username' => $username,
|
'username' => $username,
|
||||||
'datasource' => $datasource,
|
'datasource' => $datasource,
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
$output["error"]="access not granted";
|
|
||||||
return new Response(json_encode($output), 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user