public function loginAction()
 {
     // action body
     $request = $this->getRequest();
     $form = new Application_Form_Login();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $bootstrap = $this->getInvokeArg('bootstrap');
             $dbAdapter = $bootstrap->getResource('db');
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter, 'user', 'name', 'password');
             $data = $form->getValidValues($request->getPost());
             $authAdapter->setIdentity($data['name']);
             $password = sha1($data['password']);
             $authAdapter->setCredential($password);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $user = $authAdapter->getResultRowObject(null, 'password');
                 $storage = $auth->getStorage();
                 $storage->write($user);
                 if ($user->confirmed == 1) {
                     $this->_redirect('dashboard');
                     // Redirect to dashboard
                 } else {
                     Zend_Auth::getInstance()->clearIdentity();
                     $this->view->errors = array('You\'re registration is not yet confirmed');
                 }
             } else {
                 $form->getElement('password')->addError('Invalid password.');
             }
         }
     }
     $this->view->form = $form;
 }