api edispatcher/api/checkuser (ref #31889)
This commit is contained in:
parent
6d04f2a08e
commit
cf91d5c9cd
@ -71,6 +71,39 @@ class ApiController extends Controller
|
||||
return new Response(json_encode($reponse), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function checkuserAction() {
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$id = $request->query->get('id',false);
|
||||
|
||||
if ($id) {
|
||||
|
||||
$user=$em->getRepository('CadolesCoreBundle:User')->findOneBy(["username"=>$id]);
|
||||
|
||||
if (!$user) {
|
||||
$output["error"]="id=".$id." : user not found";
|
||||
return new Response(json_encode($output), 400);
|
||||
}
|
||||
$output["username"] = $user->getUsername();
|
||||
$output["firstname"] = $user->getFirstname();
|
||||
$output["lastname"] = $user->getLastname();
|
||||
$output["email"] = $user->getEmail();
|
||||
$output["role"] = $user->getRole();
|
||||
foreach($user->getGroups() as $group) {
|
||||
$output["groupes"][] = $group->getGroup()->getLabel();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$output["error"]="id needed";
|
||||
return new Response(json_encode($output), 404);
|
||||
|
||||
}
|
||||
return new Response(json_encode($output), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
|
||||
public function testAction() {
|
||||
|
||||
|
@ -29,6 +29,10 @@ cadoles_edispatcher_api_applications:
|
||||
path: /edispatcher/api/applications
|
||||
defaults: { _controller: CadolesEdispatcherBundle:Api:applications }
|
||||
|
||||
cadoles_edispatcher_api_checkuser:
|
||||
path: /edispatcher/api/checkuser
|
||||
defaults: { _controller: CadolesEdispatcherBundle:Api:checkuser }
|
||||
|
||||
cadoles_edispatcher_api_apps_all:
|
||||
path: /edispatcher/api/apps/all
|
||||
defaults: { _controller: CadolesEdispatcherBundle:Api:hello }
|
||||
|
Loading…
Reference in New Issue
Block a user