Пример #1
0
 public function loginAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('index/index');
     }
     $form = new Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $authAdapter = $this->getAdapter();
             $username = $form->getValue('username');
             $password = $form->getValue('password');
             $authAdapter->setIdentity($username)->setCredential($password);
             echo 'start';
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             echo 'end';
             if ($result->isValid()) {
                 $identity = $authAdapter->getResultRowObject();
                 $authStorage = $auth->getStorage();
                 $authStorage->write($identity);
                 echo 'ok';
                 //$this->_redirect('index/index');
             } else {
                 echo 'no';
                 $this->view->errorMessage = '<ul class="error"><li>Username or password is wrong!</li></ul>';
             }
         }
     }
     $form->setAction('../authentication/login');
     $this->view->form = $form;
 }
 public function indexAction()
 {
     $formLogin = new Form_Login();
     $formLogin->setAction($this->view->url(array('controller' => 'session', 'action' => 'login')));
     $this->view->formLogin = $formLogin;
     $formSignUp = new Form_Usuario();
     $formSignUp->removeElement('saldo');
     $formSignUp->removeElement('energia');
     $formSignUp->setAction($this->view->url(array('controller' => 'session', 'action' => 'sign-up')));
     $this->view->formSignUp = $formSignUp;
 }
Пример #3
0
 public function indexAction()
 {
     // Rate limit the login form by IP address, with a maximum of 10 requests every 5 minutes
     $rateLimit = new Noginn_RateLimit(array('login', $_SERVER['REMOTE_ADDR']), 10, 5);
     $form = new Form_Login();
     if ($rateLimit->exceeded()) {
         // A CAPTCHA is added to the form is the rate limit is exceeded
         $form->addCaptcha();
     }
     if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
         // Validate the login
         $values = $form->getValues();
         if ($values['username'] == $this->_username && $values['password'] == $this->_password) {
             // Correct login, continue
             $this->_helper->redirector('account');
         } else {
             // Increment request count for failed login attempts
             $rateLimit->increment();
         }
     }
     $form->setAction($this->_helper->url->url());
     $this->view->form = $form;
     $this->view->rateLimit = $rateLimit;
 }