Example #1
0
 public function signOutAction(Request $request)
 {
     try {
         $redirectUrl = $this->generateUrl($this->getParameters('admin-bundle.logout_url'));
     } catch (\Exception $e) {
         if (!$request->request->has('redirect_url')) {
             throw new ServerInternalErrorException('redirect_url unconfiguration.');
         }
         $redirectUrl = $request->request->get('logout_url');
     }
     $request->clearSession('manager');
     if ($request->hasSession('manager')) {
         if ($request->isXmlHttpRequest()) {
             return new JsonResponse(['code' => 10088, 'msg' => 'Operation fail.'], Response::HTTP_BAD_REQUEST);
         }
         return $this->redirect($redirectUrl);
     }
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(['msg' => 'ok']);
     }
     return $this->redirect($redirectUrl);
 }