Merge branch 'master' into dist/envole/6/master
This commit is contained in:
commit
cce91c421a
|
@ -69,16 +69,28 @@ 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')]))
|
||||||
return $this->render('CadolesEdispatcherBundle:Test:test.html.twig',[
|
$login = $attributes[$this->getParameter('user_attr_cas_username')];
|
||||||
'useheader' => true,
|
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$login]);
|
||||||
'usemenu' => false,
|
if(!$user) {
|
||||||
'usesidebar' => false,
|
$output["error"]="user does not exist";
|
||||||
'attributes' => $attributes,
|
return new Response(json_encode($output), 400);
|
||||||
'groups' => $groups,
|
}
|
||||||
'username' => $username,
|
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
||||||
'datasource' => $datasource,
|
if (in_array("ROLE_ADMIN",$roles)) {
|
||||||
]);
|
return $this->render('CadolesEdispatcherBundle:Test:test.html.twig',[
|
||||||
|
'useheader' => true,
|
||||||
|
'usemenu' => false,
|
||||||
|
'usesidebar' => false,
|
||||||
|
'attributes' => $attributes,
|
||||||
|
'groups' => $groups,
|
||||||
|
'username' => $username,
|
||||||
|
'datasource' => $datasource,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$output["error"]="access not granted";
|
||||||
|
return new Response(json_encode($output), 403);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue