Guest User

Untitled

a guest
Jul 21st, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. <?php
  2.  
  3. class IndexController extends Zend_Controller_Action {
  4. public function init() {
  5. //$this->view->login_name=Zend_Registry::get('login_name');
  6. }
  7.  
  8. public function indexAction() {
  9. $storage = new Zend_Auth_Storage_Session();
  10. $data = $storage->read();
  11. if(!$data){
  12. $this->_redirect('index/login');
  13. }
  14.  
  15. $this->view->mainourbank='yes';
  16.  
  17. }
  18.  
  19. public function viewAction() {
  20. $posts = new Posts();
  21. $this->view->result = $posts->getPosts();
  22. // $loginDetails = Zend_Auth::getInstance()->getIdentity();
  23. // $this->view->username = $loginDetails->login_name;
  24. // $user_id=$loginDetails->user_id;
  25. // $this->view->user_id=$user_id;
  26. // $this->view->title = "Main Page- Ourbank";
  27. }
  28.  
  29. public function loginAction()
  30. {
  31. $this->_helper->layout->disableLayout();
  32. $loginForm = new Login();
  33. $redirect = $this->getRequest()->getParam('redirect', 'index/view');
  34. $loginForm->setAttrib('redirect', $redirect );
  35. $auth = Zend_Auth::getInstance();
  36. if(Zend_Auth::getInstance()->hasIdentity()) {
  37. $this->_redirect('/index/view');
  38. } else if ($this->getRequest()->isPost()) {
  39. if ( $loginForm->isValid($this->getRequest()->getPost()) ) {
  40.  
  41. $username = $this->getRequest()->getPost('username');
  42.  
  43. /*
  44. * Get password
  45. */
  46. $pwd = $this->getRequest()->getPost('pass');
  47. /*
  48. * Create object $authAdapter of class Model_AuthAdapter
  49.  
  50. */
  51.  
  52. $authAdapter = new AuthAdapter($username, $pwd);
  53. /*
  54. * Try to authenticate and check whether its valid
  55. */
  56. $result = $auth->authenticate($authAdapter);
  57. if(!$result->isValid()) {
  58. switch ($result->getCode()) {
  59. case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
  60. $this->view->error = 'user credentials not found';
  61. }
  62. } else {
  63. echo "Am new".$username;
  64. $tre = new Acl();
  65. $tre->passingUsername($username);
  66. /*
  67. * If its valid redirect it . Now it will not work ;) .
  68. * Have not implemented the redirect to the page from where it came.
  69. */
  70. //$this->_redirect( $redirect );
  71. }
  72. }
  73. }
  74. /*
  75. * Assign the form elements to view
  76. */
  77. $this->view->loginForm = $loginForm;
  78. }
  79.  
  80. public function logoutAction()
  81. {
  82. /*
  83. * Logout and clear session
  84. */
  85. $auth = Zend_Auth::getInstance();
  86. $auth->clearIdentity();
  87. $this->_redirect('/');
  88. }
  89.  
  90. public function registerAction()
  91. {
  92. /*
  93. * Register for new account
  94. */
  95. $register = new Form_Registration();
  96. if(Zend_Auth::getInstance()->hasIdentity()) {
  97. $this->_redirect('/index/hello');
  98. } else if ($this->getRequest()->isPost()) {
  99. if ( $register->isValid($this->getRequest()->getPost()) ) {
  100.  
  101. }
  102. }
  103. $this->view->register = $register;
  104. }
  105.  
  106. public function forgotPasswordAction()
  107. {
  108. /*
  109. * User submits for new password
  110. */
  111. $forgotPassword = new Form_ForgotPassword();
  112. if(Zend_Auth::getInstance()->hasIdentity()) {
  113. $this->_redirect('/index/hello');
  114. } else if ($this->getRequest()->isPost()) {
  115. if ( $forgotPassword->isValid($this->getRequest()->getPost()) ) {
  116.  
  117. }
  118. }
  119. $this->view->forgotPassword = $forgotPassword;
  120. }
  121. }
Add Comment
Please, Sign In to add comment