Example #1
0
 public function deleteganAction()
 {
     $ganID = $this->_request->getParam('g');
     $gan_DB = new Application_Model_DbTable_Gan();
     $gan_DB->delete("ganID = {$ganID}");
     $this->_redirect("/admin/gan");
 }
 /**
  * This action check the user login 
  * 
  */
 public function checkAction()
 {
     $request = $this->getRequest();
     $user_data = $request->getPost();
     //$authAdapter = $this->getAuthAdapter();
     # get the username and password from the form
     $username = trim($user_data['username']);
     $password = trim($user_data['password']);
     $remember_me = isset($user_data['rememberme']) && $user_data['rememberme'];
     if (!strlen($username)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('MISSING_USERNAME') . '</div>');
         $this->_redirect('/');
     }
     if (!strlen($password)) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('MISSING_PASSWORD') . '</div>');
         $this->_redirect('/');
     }
     # pass to the adapter the submitted username and password
     $authAdapter = $this->getAuthAdapter();
     $authAdapter->setIdentity($username)->setCredential($password);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     $user_DB = new Application_Model_DbTable_Gan();
     $user_Info = $user_DB->getGanInfo($username);
     if (!$user_Info) {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('NOT_VERIFIED') . '</div>');
         $this->_redirect('/');
     }
     # is the user a valid one?
     if ($result->isValid()) {
         # all info about this user from the login table
         # ommit only the password, we don't need that
         $userInfo = $authAdapter->getResultRowObject(null, 'password');
         # the default storage is a session with namespace Zend_Auth
         $authStorage = $auth->getStorage();
         $authStorage->write($userInfo);
         // print_r ($userInfo);die;
         // Throw signin event
         //            topxiteHooksRegistry::dispatchEvent('onSignIn', $userInfo);
         # remeber me
         // $seconds  = 6048000; // 70 days
         // if ($remember_me) {
         //  Zend_Session::RememberMe($seconds);
         //}
         // else {
         //   Zend_Session::ForgetMe();
         //}
         //            topxiteHooksRegistry::dispatchEvent('lastLogin', $userInfo);
         //$user = new Application_Model_DbTable_Users();
         //$user->setLastLogin($userInfo->user_id);
         $this->_redirect('/groups');
     } else {
         $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">&times;</button>' . $this->lang->_('WRONG_LOGIN') . '</div>');
         $this->_redirect('/');
     }
 }