public function logowanieAction()
 {
     $this->view->title = 'Logowanie';
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('/');
     }
     $request = $this->getRequest();
     $form = new Form_Login();
     if ($request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $authAdapter = $this->getAuthAdapter();
             $username = $form->getValue('username');
             $password = $form->getValue('password');
             $authAdapter->setIdentity($username)->setCredential($password)->setCredentialTreatment('MD5(?)');
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $identity = $authAdapter->getResultRowObject();
                 $authStorage = $auth->getStorage();
                 $authStorage->write($identity);
                 $server = new Zend_View_Helper_ServerUrl();
                 $server->setScheme('http');
                 $this->_redirect($server->serverUrl($this->view->url(array('controller' => 'zdjecia', 'action' => 'index'))));
                 //                    $this->_redirect('/zdjecia/');
             } else {
                 $this->view->errorMessage = 'Nieprawidłowa nazwa użytkownika lub hasło.';
             }
         }
     }
     $this->view->form = $form;
 }
 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 loginAction()
 {
     $this->view->title = 'Login';
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_redirect('index/index');
     }
     $request = $this->getRequest();
     $form = new Form_Login();
     if ($request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $authAdapter = $this->getAuthAdapter();
             $user = $form->getValue('username');
             $password = $form->getValue('password');
             $authAdapter->setIdentity($user)->setCredential($password);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             if ($result->isValid()) {
                 $identity = $authAdapter->getResultRowObject();
                 $authStorage = $auth->getStorage();
                 $authStorage->write($identity);
                 $this->_redirect('index/index');
             } else {
                 echo $this->view->errorMessage = "Username and password does not match";
             }
         }
     }
     $this->view->form = $form;
 }
 public function loginAction()
 {
     $formLogin = new Form_Login();
     if ($this->_request->isPost()) {
         if ($formLogin->isValid($this->_request->getParams())) {
             $user = new Model_User();
             if ($user->authorize($formLogin->getValue('email'), $formLogin->getValue('password'))) {
                 $this->_helper->redirector('index');
             } else {
                 $this->view->error = 'Неверные данные авторизации';
             }
         }
     }
     $this->view->form = $formLogin;
 }
 public function loginAction()
 {
     $this->view->title = "User Login.";
     $this->view->headTitle($this->view->title, 'PREPEND');
     $form = new Form_Login();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $user = new Model_User();
             if ($user->authorize($form->getValue('vUsername'), $form->getValue('vPassword'))) {
                 $this->_redirect('/index/');
             } else {
                 $this->view->error = "Wrong E-mail or Password.";
             }
         }
     }
     $this->view->form = $form;
 }
 public function loginAction()
 {
     $form = new Form_Login();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             if ($this->loginCheck($form->getValue('login'), $form->getValue('senha'))) {
                 return $this->_helper->redirector('index', 'index', 'default');
             } else {
                 $this->_helper->FlashMessenger(implode(' ', $this->result->getMessages()));
                 return $this->forward('index');
             }
         } else {
             $form->populate($formData);
             return $this->forward('index');
         }
     }
 }
Exemple #7
0
 public function loginAction()
 {
     $request = $this->getRequest();
     $form = new Form_Login();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $authAdapter = new Netons_AuthAdapter();
         $authAdapter->setIdentity($form->getValue('identity'));
         $authAdapter->setCredential($form->getValue('password'));
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($authAdapter);
         if ($result->isValid()) {
             $data = $authAdapter->getResultRowObject(null, 'password');
             $auth->getStorage()->write($data);
             $this->_redirector->gotoSimple('index', 'index');
         } else {
             $this->view->errors = array('Wrong username or password.');
         }
     }
     $this->view->headTitle('Login');
     $this->view->form = $form;
 }
 public function indexAction()
 {
     $this->view->title = "Página de Login do Projeto Piloto";
     $this->_helper->layout->setLayout('login');
     $form = new Form_Login();
     $data = $this->_getAllParams();
     $this->view->form = $form;
     if ($this->_getParam('sessao') == 'expirada') {
         $this->view->message_sessao = "Sua sessão expirou, favor logar novamente";
     }
     try {
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $userNs = new Zend_Session_Namespace('userNs');
                 $authAdapter = new App_Auth_Adapter_Db();
                 $authAdapter->setIdentity($form->getValue('COU_COD_MATRICULA'));
                 $authAdapter->setCredential($form->getValue('COU_COD_PASSWORD'));
                 $authAdapter->setDbName($form->getValue('COU_NM_BANCO'));
                 $uf = strtoupper(substr($form->getValue('COU_COD_MATRICULA'), 0, 2));
                 $auth = Zend_Auth::getInstance();
                 $result = $auth->authenticate($authAdapter);
                 $messageLogin = $result->getMessages();
                 if ($result->isValid()) {
                     $data = $authAdapter->getResultRowObject(null, 'COU_COD_PASSWORD');
                     $userNs->matricula = strtoupper($form->getValue('COU_COD_MATRICULA'));
                     $userNs->banco = $messageLogin[1];
                     $userNs->codSec = $messageLogin[2];
                     $userNs->perfil = 'usuario';
                     $userNs->uf = $uf;
                     $userNs->nome = 'Marcelo Caixeta Rocha';
                     $userNs->siglasecao = 'TR';
                     $userNs->codlotacao = 1133;
                     $userNs->siglalotacao = 'DISAD';
                     $userNs->descicaolotacao = 'DIVISÃO DE SISTEMAS ADMINISTRATIVOS';
                     $userNs->localizacao = '';
                     $userNs->email = strtolower($form->getValue('COU_COD_MATRICULA')) . '@trf1.jus.br';
                     return $this->_helper->_redirector('index', 'fase-administrativa', 'sisad');
                 } else {
                     $this->view->message = $messageLogin[0];
                 }
             }
         }
     } catch (Exception $e) {
         $e = 'Logon Negado';
         $this->view->message = $e;
     }
 }
 public function loginAction()
 {
     $form = new Form_Login();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $user = new Model_User();
             //authorize() - фу-я описана в моделі,
             //повертає true, якщо авторизація пройшла успішно
             if ($user->authorize($form->getValue('username'), $form->getValue('password'))) {
                 $this->_helper->redirector('login');
             } else {
                 $this->view->error = "Невірні дані авторизації";
             }
         }
     }
     $this->view->form = $form;
 }
Exemple #10
0
 public function loginAction()
 {
     $form = new Form_Login();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $user = new Model_User();
             if ($user->authorize($form->getValue('username'), $form->getValue('password'))) {
                 $this->_helper->redirector('login');
             } else {
                 $this->view->error = 'Неверные данные авторизации.';
             }
         }
     }
     $this->view->form = $form;
 }
 /**
  * Rotina de login
  */
 public function loginAction()
 {
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $this->view->messages = $this->_flashMessenger->getMessages();
     $form = new Form_Login();
     $this->view->form = $form;
     /*
      * Verifica se existem dados de POST
      */
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         /*
          * Formulário corretamente preenchido?
          */
         if ($form->isValid($data)) {
             $login = $form->getValue('login');
             $senha = $form->getValue('senha');
             $dbAdapter = Zend_Db_Table::getDefaultAdapter();
             /*
              * Inicia o adaptador Zend_Auth para banco de dados
              */
             $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
             $authAdapter->setTableName('usuarios')->setIdentityColumn('login')->setCredentialColumn('senha')->setCredentialTreatment('SHA1(?)');
             /*
              * Define os dados para processar o login
              */
             $authAdapter->setIdentity($login)->setCredential($senha);
             /*
              * Efetua o login
              */
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($authAdapter);
             /*
              * Verifica se o login foi efetuado com sucesso
              */
             if ($result->isValid()) {
                 /*
                  * Armazena os dados do usuário em sessão, apenas desconsiderando                     
                  * a senha do usuário
                  */
                 $info = $authAdapter->getResultRowObject(null, 'senha');
                 $storage = $auth->getStorage();
                 $storage->write($info);
                 /*
                  * Redireciona para o Controller protegido
                  */
                 return $this->_helper->redirector->goToRoute(array('controller' => 'index'), null, true);
             } else {
                 /*
                  * Dados inválidos
                  */
                 $this->_helper->FlashMessenger('Usu&aacute;rio ou senha inv&aacute;lidos!');
                 $this->_redirect('/auth/login');
             }
         } else {
             /*
              * Formulário preenchido de forma incorreta
              */
             $form->populate($data);
         }
     }
 }