예제 #1
0
 public function loginAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $storage = new Zend_Auth_Storage_Session();
         $storage->clear();
     }
     $users = new Application_Model_User();
     $form = new Application_Form_Login();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $auth = Zend_Auth::getInstance();
             $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'user');
             $authAdapter->setIdentityColumn('name')->setCredentialColumn('password');
             $authAdapter->setIdentity($data['name'])->setCredential($data['password']);
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $storage = new Zend_Auth_Storage_Session();
                 $storage->write($authAdapter->getResultRowObject(array('id', 'name', 'image')));
                 if ($auth->getIdentity()->name == 'admin') {
                     $this->redirect("Order/adminhome");
                 } elseif ($auth->getIdentity()->name != 'admin') {
                     $this->redirect("Order/adduserorder");
                 }
             } else {
                 $this->view->errorMessage = "Invalid username or password. Please try again.";
             }
         }
     }
 }
예제 #2
0
 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->_request;
     $auth = Zend_Auth::getInstance();
     if ($request->isPost()) {
         $data = $request->getPost();
         if ($form->isValid($data)) {
             $data = $form->getValues();
             $login = Application_Model_Login::login($data['email'], $data['senha']);
             if ($login === true) {
                 $this->redirect('/index');
             } else {
                 $this->_helper->FlashMessenger->addMessage($login);
                 $this->view->messages = $this->_helper->FlashMessenger->getMessages();
                 $form->populate($data);
             }
         }
     } else {
         $this->view->messages = $this->_helper->FlashMessenger->getMessages();
     }
     if ($auth->hasIdentity()) {
         $this->redirect('/index');
     }
     $this->view->form = $form;
     $this->view->logourl = $this->_custom['logourl'];
     $this->view->company_name = $this->_custom['company_name'];
 }
예제 #3
0
 public function indexAction()
 {
     if ($this->auth->hasIdentity()) {
         $this->_helper->redirector('index', 'index');
     }
     $translator = Zend_Registry::get('container')->getService('translator');
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         $adapter = $this->_helper->service('auth.adapter');
         $adapter->setEmail($values['email'])->setPassword($values['password']);
         $result = $this->auth->authenticate($adapter);
         if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
             $expire = null;
             if (!empty($values['remember_me'])) {
                 // set expire to 10 years in the future
                 $expire = time() + 10 * 365 * 24 * 60 * 60;
             }
             setcookie('NO_CACHE', '1', $expire, '/', '.' . $this->extractDomain($_SERVER['HTTP_HOST']));
             if (isset($values['_target_path'])) {
                 $this->_helper->redirector->gotoUrl($values['_target_path']);
             }
             $this->_helper->redirector('index', 'dashboard');
         } else {
             $form->addError($translator->trans("Invalid credentials"));
         }
     }
     $this->view->form = $form;
 }
예제 #4
0
 public function loginAction()
 {
     $form = new Application_Form_Login();
             $request = $this->getRequest();
             if ($request->isPost()) {
                 if ($form->isValid($request->getPost())) {
                     if ($this->_process($form->getValues())) {
                         // We're authenticated! Redirect to the home page
                         
                         Log_Admin::GoodEnter($form->getValues());
                         $this->_helper->redirector('index', 'hna');
                     } else {
                         Log_Admin::BadEnter($form->getValues());
                         echo "Ошибка! Проверьте правильность введенных данных!";
                     }
                 }
             }
             $this->view->form = $form;
 }
예제 #5
0
 public function loginAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             if ($this->_process($form->getValues())) {
                 $this->_helper->redirector('index', 'index');
             }
         }
     }
     $this->view->form = $form;
 }
예제 #6
0
 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             if ($this->_process($form->getValues())) {
                 // We're authenticated! Redirect to the home page
                 $this->_helper->redirector('index', 'index');
             }
         }
     }
     $this->view->form = $form;
 }
예제 #7
0
 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             if ($this->_process($form->getValues())) {
                 //success means authenticate criteria has been met
                 $this->_helper->redirector('setparam', 'multi');
             }
         }
     }
     $this->view->form = $form;
 }
예제 #8
0
 public function loginAction()
 {
     $this->_helper->layout->setLayout('layout_login');
     $form = new Application_Form_Login();
     $params = $this->_request->getParams();
     if ($this->_request->isPost() && $form->isValid($params)) {
         $_usuario = new Application_Model_Usuario();
         $loginValido = $_usuario->autenticar($form->getValues());
         if ($loginValido) {
             $this->_redirect('/');
         } else {
             $this->_helper->FlashMessenger('Usuario o contraseña invalido');
             $this->_redirect('/index/login');
         }
     }
     $this->view->form = $form;
 }
예제 #9
0
 public function indexAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             if ($this->_process($form->getValues())) {
                 // We're authenticated! Redirect to the home page
                 $this->_helper->redirector('index', 'index');
             } else {
                 $this->_flashMessage('Login failed');
             }
         }
     }
     $this->view->form = $form;
     $flashMessenger = $this->_helper->FlashMessenger;
     $flashMessenger->setNamespace('actionErrors');
     $this->view->actionErrors = $flashMessenger->getMessages();
 }
예제 #10
0
 public function indexAction()
 {
     if ($this->auth->hasIdentity()) {
         $this->_helper->redirector('index', 'index');
     }
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         $adapter = $this->_helper->service('auth.adapter');
         $adapter->setEmail($values['email'])->setPassword($values['password']);
         $result = $this->auth->authenticate($adapter);
         if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
             $this->_helper->redirector('index', 'dashboard');
         } else {
             $form->addError($this->view->translate("Invalid credentials"));
         }
     }
     $this->view->form = $form;
 }
예제 #11
0
 public function loginAction()
 {
     Zend_Registry::get('log')->info(__METHOD__);
     $this->_helper->layout()->disableLayout();
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $userservice = App_Service_Manager::getService('user');
             if ($user = $userservice->isValid($form->getValues())) {
                 // We're authenticated! Redirect to the home page
                 Zend_Auth::getInstance()->getStorage()->write($user);
                 $acl = $userservice->getACl();
                 $session = new Zend_Session_Namespace('zend');
                 $session->acl = $acl;
                 $this->_helper->redirector('index', 'index', 'admin');
             }
         }
     }
     $this->view->form = $form;
 }
예제 #12
0
 public function loginAction()
 {
     //Use of session to store login and logout user
     $authns = new Zend_Session_Namespace('AuthNameSpace');
     if (isset($authns->userId)) {
         //User has already logged in before
         $mapper = new Application_Model_MemberMapper();
         $member = new Application_Model_Member();
         $mapper->find($authns->userId, $member);
         if ($mapper->login($member)) {
             // return $this->_redirect('/');
             $this->_redirector->gotoSimple('view', 'ideas', null, array());
         }
     }
     //User has not yet login, present login form
     $loginForm = new Application_Form_Login();
     if ($this->getRequest()->isPost()) {
         if ($loginForm->isValid($this->getRequest()->getPost())) {
             $member = new Application_Model_Member($loginForm->getValues());
             $mapper = new Application_Model_MemberMapper();
             //If the user has registered
             if ($mapper->login($member)) {
                 //Use of session to store login and logout user
                 $authns = new Zend_Session_Namespace('AuthNameSpace');
                 if (!isset($authns->userId)) {
                     //Retrieve the user ID
                     $authns->userId = $member->getMemberLogin();
                 }
                 // return $this->_redirect('/');
                 $this->_redirector->gotoSimple('view', 'ideas', null, array());
             } else {
                 $this->_helper->FlashMessenger()->setNamespace('error')->addMessage('Login Failed.');
                 // return $this->_redirect('/members/login/');
                 $this->_redirector->gotoSimple('login', 'members', null, array());
             }
         }
     }
     $this->view->loginForm = $loginForm;
 }
 /**
  * Function for logincheckAction which check user's given email and password.
  */
 public function logincheckAction()
 {
     $form = new Application_Form_Login();
     $this->view->form = $form;
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $adapter = $this->_getAuthAdapter($form->getValues());
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($adapter);
             if ($result->isValid()) {
                 $oSessionNamespace = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
                 $oSessionNamespace->setExpirationSeconds(600);
                 $this->_redirect('/user/list');
             } else {
                 $this->view->errorMessage = "Invalid username or password. Please try again.";
             }
         }
     }
     $this->render('index');
     $this->_helper->_layout->setLayout('loginlayout');
 }
 public function example6submitAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_Login();
     $success = false;
     $message = null;
     $username = $request->getParam('username');
     $password = $request->getParam('password');
     //error_log('uname: '.$username.' -> '.$password);
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $result = $this->_checkDbLogin($form->getValues());
             $success = $result['success'];
             $message = $result['message'];
         }
     }
     $this->view->success = $success;
     $this->view->message = $message;
 }
 public function loginAction()
 {
     $form = new Application_Form_Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $result = $this->_process($form->getValues());
             if ($result->isValid()) {
                 if ($form->getValue('rememberMe') == 1) {
                     // REMEMBER THE SESSION FOR 1 DAYS
                     Zend_Session::rememberMe(self::REMEMBER_DAYS * self::SECONDS_IN_DAY);
                     // 1 days
                 } else {
                     // DO NOT REMEMBER THE SESSION
                     Zend_Session::forgetMe();
                     $session = new Zend_Session_Namespace('Zend_Auth');
                     $session->setExpirationSeconds(self::SECONDS_IN_MINUTE * self::EXPIRATION_MINUTES);
                 }
                 // We're authenticated! Redirect to the home page
                 $this->_helper->redirector('index', 'index');
             } else {
                 foreach ($result->getMessages() as $message) {
                     $this->_helper->getHelper('FlashMessenger')->addMessage($message, 'error');
                     $this->_helper->redirector('login');
                 }
             }
         }
     }
     $this->view->form = $form;
 }
예제 #16
0
 /**
  * Mapeada como
  *    /login
  */
 public function loginAction()
 {
     $isMobile = false;
     $mobile = new Sige_Mobile_Browser();
     if ($mobile->isMobile()) {
         $this->_helper->layout->setLayout('mobile');
         $isMobile = true;
         $form = new Mobile_Form_Login();
         $this->_helper->viewRenderer('mobile-login');
     } else {
         $this->_helper->layout->setLayout('twbs3/front-page');
         $form = new Application_Form_Login();
     }
     $this->view->form = $form;
     $data = $this->getRequest()->getPost();
     if ($this->getRequest()->isPost() && $form->isValid($data)) {
         $data = $form->getValues();
         $model = new Application_Model_Pessoa();
         $resultadoConsulta = $model->avaliaLogin($data['email'], $data['senha']);
         if ($resultadoConsulta != NULL) {
             $idPessoa = $resultadoConsulta['id_pessoa'];
             $administrador = $resultadoConsulta['administrador'];
             $apelido = $resultadoConsulta['apelido'];
             $twitter = $resultadoConsulta['twitter'];
             $cadastro_validado = $resultadoConsulta['cadastro_validado'];
             if ($cadastro_validado == false) {
                 $where = $model->getAdapter()->quoteInto('id_pessoa = ?', $idPessoa);
                 $model->update(array('cadastro_validado' => true), $where);
             }
             $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
             $idEncontro = $config->encontro->codigo;
             $result = $model->buscarUltimoEncontro($idPessoa);
             $irParaEditar = false;
             // se ultimo encontro do participante for diferente do atual
             if ($model->verificaEncontro($idEncontro, $idPessoa) == false) {
                 $result['id_encontro'] = intval($idEncontro);
                 // forçar participante validado : issue #32
                 $result['validado'] = 't';
                 // true
                 $result['data_validacao'] = new Zend_Db_Expr('now()');
                 try {
                     $model->getAdapter()->insert("encontro_participante", $result);
                     $this->_helper->flashMessenger->addMessage(array('success' => _('Welcome back. Your registration was confirmed!<br/>Please update your profile data.')));
                     $irParaEditar = true;
                     $this->_enviarEmailConfirmacaoInscricao($idEncontro, $idPessoa);
                 } catch (Exception $e) {
                     $irParaEditar = false;
                     $this->_helper->flashMessenger->addMessage(array('danger' => $e->getMessage()));
                 }
             } else {
                 if (!$result['validado']) {
                     // se participante ainda não está validado no encontro
                     // devemos validar
                     $adapter = $model->getAdapter();
                     $adapter->fetchAll("UPDATE encontro_participante\n                    SET validado = 't', data_validacao = now()\n                    WHERE id_pessoa = {$result['id_pessoa']}\n                    AND id_encontro = {$idEncontro}");
                 }
             }
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $storage->write(array("idPessoa" => $idPessoa, "administrador" => $administrador, "apelido" => $apelido, "idEncontro" => $idEncontro, "twitter" => $twitter, "email" => $data['email']));
             if ($isMobile) {
                 return $this->_helper->redirector->goToRoute(array(), 'mobile', true);
             } else {
                 if ($irParaEditar) {
                     return $this->_helper->redirector->goToRoute(array('controller' => 'participante', 'action' => 'editar'), 'default', true);
                 } else {
                     $session = new Zend_Session_Namespace();
                     if (isset($session->url)) {
                         $this->_redirect($session->url, array('prependBase' => false));
                         unset($session->url);
                     } else {
                         return $this->_helper->redirector->goToRoute(array('controller' => 'participante', 'action' => 'index'), 'default', true);
                     }
                 }
             }
         } else {
             $this->_helper->flashMessenger->addMessage(array('danger' => _('E-mail or Password incorrect.')));
         }
     }
 }