code: public function loginAction() 
      {
  		$this->getResponse()
  			->setStatusCode(Response::STATUS_CODE_201);
  		
  		$request = $this->getRequest();
  		$content = $request->getContent();
  		$content = !empty($content) ? Json::decode($content, Json::TYPE_ARRAY) : array();
  		$post = array_merge_recursive(
  			$request->getPost()->toArray(),
  			$content
  		);
  		
      	$form = $this->getLoginForm();
  		$form->setData($post);
  		
  		if ($form->isValid()) {
  			try {
  				// clear adapters
  				$this->zfcUserAuthentication()->getAuthAdapter()->resetAdapters();
  				$this->zfcUserAuthentication()->getAuthService()->clearIdentity();
  				$r = $this->forward()->dispatch('user', array('action' => 'authenticate'));
  				
  				if(true === $r->id) {
  					$data = array(
  						'id' => $r->id
  					);
  				} else {
  					$this->getResponse()
  						->setStatusCode(Response::STATUS_CODE_500);
  					return new JsonModel(array(
  						'status' => "danger",
  						'message' => "Nessun utente corrisponde alle credenziali inviate"
  					));
  				}
  			} catch(\Exception $e) {
  				$this->getResponse()
  					->setStatusCode(Response::STATUS_CODE_500);
  // 				$data = array(
  // 					'csrf' => $e->getMessage()
  // 				);
  					return new JsonModel(array(
  						'status' => "danger",
  						'message' => "Nessun utente corrisponde alle credenziali inviate (" . $e->getMessage() . ")"
  					));
  			}
  		} else {
  			$this->getResponse()
  				->setStatusCode(Response::STATUS_CODE_500);
  			$data = $form->getMessages();
  		}
  		
  		return new JsonModel($data);
      }
docs: (non-PHPdoc)
  @see \ZfcUser\Controller\UserController::loginAction()