Advertisement
Guest User

Untitled

a guest
Sep 30th, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. public function loginAction()
  2. {
  3. $request = $this->getRequest();
  4. $session = new Zend_Session_Namespace('Auth_Public_Site');
  5. $resp = array();
  6.  
  7. if ($request->isPost()) {
  8.  
  9. if($request->isXmlHttpRequest()){
  10.  
  11. $username = $request->getPost('login_user');
  12. $password = $request->getPost('login_pass');
  13. //$redirect = $request->getPost('redirect');
  14. $adapter = new Profile_Services_Auth($username, $password);
  15. $result = $adapter->authenticate();
  16.  
  17. switch ($result->getCode()) {
  18. /**
  19. * Found user, but the account has not been activated
  20. */
  21. case Profile_Services_Auth::NOT_ACTIVE:
  22. $resp = array(
  23. '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',
  24. 'status' => 'error',
  25. );
  26. break;
  27.  
  28. /**
  29. * Logged in successfully
  30. */
  31. case Profile_Services_Auth::SUCCESS:
  32.  
  33. $redirect = $this->view->url(array(),'profile_private_artist');
  34.  
  35. $session->user = $result->getIdentity();
  36.  
  37. // Resposta
  38. $resp = array(
  39. 'redirect' => $redirect,
  40. 'message' => 'Login realizado com sucesso',
  41. 'status' => 'ok',
  42. );
  43. break;
  44.  
  45. /**
  46. * Not found
  47. */
  48. case Profile_Services_Auth::FAILURE:
  49. default:
  50. $resp = array(
  51. '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',
  52. 'status' => 'error',
  53. );
  54. break;
  55. }
  56.  
  57.  
  58.  
  59.  
  60. // Solicitação não é do tipo via AJAX
  61. }else{
  62. $resp = array(
  63. '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',
  64. 'status' => 'error',
  65. );
  66. }
  67.  
  68. // Solicitação não foi feita via POST
  69. }else{
  70. $resp = array(
  71. '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',
  72. 'status' => 'error',
  73. );
  74. }
  75.  
  76. //}
  77.  
  78. $this->_helper->json($resp);
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement