Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function loginAction()
- {
- $request = $this->getRequest();
- $session = new Zend_Session_Namespace('Auth_Public_Site');
- $resp = array();
- if ($request->isPost()) {
- if($request->isXmlHttpRequest()){
- $username = $request->getPost('login_user');
- $password = $request->getPost('login_pass');
- //$redirect = $request->getPost('redirect');
- $adapter = new Profile_Services_Auth($username, $password);
- $result = $adapter->authenticate();
- switch ($result->getCode()) {
- /**
- * Found user, but the account has not been activated
- */
- case Profile_Services_Auth::NOT_ACTIVE:
- $resp = array(
- 'message' => '<img src="'.$this->view->APP_STATIC_SERVER.'/skins/'.$this->view->APP_TEMPLATE.'/'.$this->view->APP_SKIN.'/images/icon_error.png" width="16px" height="16px" alt="" /> conta desativada',
- 'status' => 'error',
- );
- break;
- /**
- * Logged in successfully
- */
- case Profile_Services_Auth::SUCCESS:
- $redirect = $this->view->url(array(),'profile_private_artist');
- $session->user = $result->getIdentity();
- // Resposta
- $resp = array(
- 'redirect' => $redirect,
- 'message' => 'Login realizado com sucesso',
- 'status' => 'ok',
- );
- break;
- /**
- * Not found
- */
- case Profile_Services_Auth::FAILURE:
- default:
- $resp = array(
- 'message' => '<img src="'.$this->view->APP_STATIC_SERVER.'/skins/'.$this->view->APP_TEMPLATE.'/'.$this->view->APP_SKIN.'/images/icon_error.png" width="16px" height="16px" alt="" /> login ou senha incorretos',
- 'status' => 'error',
- );
- break;
- }
- // Solicitação não é do tipo via AJAX
- }else{
- $resp = array(
- 'message' => '<img src="'.$this->view->APP_STATIC_SERVER.'/skins/'.$this->view->APP_TEMPLATE.'/'.$this->view->APP_SKIN.'/images/icon_error.png" width="16px" height="16px" alt="" /> solicitação inválida',
- 'status' => 'error',
- );
- }
- // Solicitação não foi feita via POST
- }else{
- $resp = array(
- 'message' => '<img src="'.$this->view->APP_STATIC_SERVER.'/skins/'.$this->view->APP_TEMPLATE.'/'.$this->view->APP_SKIN.'/images/icon_error.png" width="16px" height="16px" alt="" /> solicitação inválida',
- 'status' => 'error',
- );
- }
- //}
- $this->_helper->json($resp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement