Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class IndexController extends Zend_Controller_Action {
- public function init() {
- //$this->view->login_name=Zend_Registry::get('login_name');
- }
- public function indexAction() {
- $storage = new Zend_Auth_Storage_Session();
- $data = $storage->read();
- if(!$data){
- $this->_redirect('index/login');
- }
- $this->view->mainourbank='yes';
- }
- public function viewAction() {
- $posts = new Posts();
- $this->view->result = $posts->getPosts();
- // $loginDetails = Zend_Auth::getInstance()->getIdentity();
- // $this->view->username = $loginDetails->login_name;
- // $user_id=$loginDetails->user_id;
- // $this->view->user_id=$user_id;
- // $this->view->title = "Main Page- Ourbank";
- }
- public function loginAction()
- {
- $this->_helper->layout->disableLayout();
- $loginForm = new Login();
- $redirect = $this->getRequest()->getParam('redirect', 'index/view');
- $loginForm->setAttrib('redirect', $redirect );
- $auth = Zend_Auth::getInstance();
- if(Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/index/view');
- } else if ($this->getRequest()->isPost()) {
- if ( $loginForm->isValid($this->getRequest()->getPost()) ) {
- $username = $this->getRequest()->getPost('username');
- /*
- * Get password
- */
- $pwd = $this->getRequest()->getPost('pass');
- /*
- * Create object $authAdapter of class Model_AuthAdapter
- */
- $authAdapter = new AuthAdapter($username, $pwd);
- /*
- * Try to authenticate and check whether its valid
- */
- $result = $auth->authenticate($authAdapter);
- if(!$result->isValid()) {
- switch ($result->getCode()) {
- case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
- $this->view->error = 'user credentials not found';
- }
- } else {
- echo "Am new".$username;
- $tre = new Acl();
- $tre->passingUsername($username);
- /*
- * If its valid redirect it . Now it will not work ;) .
- * Have not implemented the redirect to the page from where it came.
- */
- //$this->_redirect( $redirect );
- }
- }
- }
- /*
- * Assign the form elements to view
- */
- $this->view->loginForm = $loginForm;
- }
- public function logoutAction()
- {
- /*
- * Logout and clear session
- */
- $auth = Zend_Auth::getInstance();
- $auth->clearIdentity();
- $this->_redirect('/');
- }
- public function registerAction()
- {
- /*
- * Register for new account
- */
- $register = new Form_Registration();
- if(Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/index/hello');
- } else if ($this->getRequest()->isPost()) {
- if ( $register->isValid($this->getRequest()->getPost()) ) {
- }
- }
- $this->view->register = $register;
- }
- public function forgotPasswordAction()
- {
- /*
- * User submits for new password
- */
- $forgotPassword = new Form_ForgotPassword();
- if(Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/index/hello');
- } else if ($this->getRequest()->isPost()) {
- if ( $forgotPassword->isValid($this->getRequest()->getPost()) ) {
- }
- }
- $this->view->forgotPassword = $forgotPassword;
- }
- }
Add Comment
Please, Sign In to add comment