function showAll()
 {
     $form = new FormLogin($this->tpl);
     $done = $form->process();
     $this->tpl->assign("error_login", $this->request->getErrorLogin());
     $this->display();
 }
 public function actionLogin()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('document/index'));
     }
     $model = new FormLogin();
     if (isset($_POST['FormLogin'])) {
         $model->attributes = $_POST['FormLogin'];
         $model->username = $_POST['FormLogin']['username'];
         if ($model->validate() && $model->login()) {
             $this->redirect(array('document/index'));
         }
     }
     $model->password = '';
     $this->render('login', array('model' => $model));
 }
Example #3
0
 public function loginAction()
 {
     $auth = Yasui_Auth::getInstance();
     $authAdapter = $auth->getAdapter('DB');
     if ($authAdapter->isAuthenticate()) {
         $this->redirect($this->_request()->baseURL());
     }
     require 'application/forms/FormLogin.php';
     $formLogin = new FormLogin();
     if ($formLogin->formSent() && $formLogin->validateForm()) {
         if ($authAdapter->authenticate($formLogin->email, $formLogin->contrasenha)) {
             $this->redirect($this->_request()->baseURL());
         } else {
             $this->_view->mensaje = 'Usuario o contraseña erróneos';
             $this->_view->loginForm = $formLogin;
         }
     } else {
         $this->_view->loginForm = $formLogin;
     }
 }
Example #4
0
 private function hasAccess($path)
 {
     //echo file_get_contents('php://input');
     $entityBody = CJSON::decode(file_get_contents('php://input'));
     //CJSON::decode
     Yii::log("input jsond: " . CJSON::encode($entityBody), 'info', 'app');
     Yii::log("input: " . file_get_contents('php://input'), 'info', 'app');
     //
     //var_dump($entityBody);
     //exit;
     if (isset($entityBody["login_id"])) {
         $model = new FormLogin();
         $model->id = $entityBody['login_id'];
         $model->hash = $entityBody['login_hash'];
         //$model->company= $entityBody['login_company'];
         //return true;
         if ($model->apiLogin()) {
             if ((int) $entityBody['login_company'] == 0) {
                 return true;
             }
             //no company
             if (Company::model()->select((int) $entityBody['login_company'])) {
                 return true;
             }
             //needs to check access
         } else {
             return false;
         }
     }
     return false;
     //if isGuest() return false
     $arr = explode('/', $path);
     if (!isset($this->translate[$arr[0]])) {
         return false;
     }
     return Yii::app()->user->checkAccess($path);
 }
Example #5
0
<?php

require_once 'includes/common.php';
require_once 'libAllure/Form.php';
require_once 'libAllure/Session.php';
require_once 'includes/classes/FormLogin.php';
$loginForm = new FormLogin();
use libAllure\Session;
// In case of redirect...
ob_start();
global $db;
if (Session::isLoggedIn()) {
    if (isset($_REQUEST['redirect'])) {
        redirect($_REQUEST['redirect'], 'You are being redirected, hang tight!');
    } else {
        redirect('index.php', 'You are already logged in!');
    }
    require_once 'includes/widgets/footer.php';
}
if (isset($_REQUEST['username'])) {
    $loginForm->getElement('username')->setValue(filter_var($_REQUEST['username'], FILTER_SANITIZE_STRING));
}
if ($loginForm->validate()) {
    $username = $loginForm->getElementValue('username');
    $password = $loginForm->getElementValue('password');
    try {
        Session::checkCredentials($username, $password);
        applyAchievements();
        logActivity('Logged in');
        redirect('index.php', 'You have sucessfully logged in.');
    } catch (\libAllure\UserNotFoundException $e) {
Example #6
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);
/* 
 * Authors: Dennis Mohr, Nick Hoyle, Hemang Vyas
 * Date: 03/03/2016
 * Description: Profile page allows coach to view, update, delete and add a team
 *  
 */
require_once 'controller/FormLogin.php';
require_once 'dao/CoachDAO.php';
require_once 'model/CoachVO.php';
$process = new FormLogin();
?>
<div class="col-md-6">
<?php 
if (!isset($_SESSION['emailAddress'])) {
    ?>
	<h2>Login</h2>
<?php 
    if (!isset($_POST['process'])) {
        // Display the form
        $process->displayForm();
    } else {
        $form = $process->cleanForm($_POST['form']);
        $valid = $process->validateForm();
        if (empty($valid)) {
            $process->displayForm($valid);
        } else {
            $user = $GLOBALS['form']['emailAddress']['response'];
Example #7
0
<?php

require_once 'includes/common.php';
require_once 'includes/classes/FormLogin.php';
require_once 'includes/classes/FormRegister.php';
$fRegister = new FormRegister();
if ($fRegister->validate()) {
    $fRegister->process();
}
$f = new FormLogin();
if ($f->validate()) {
    try {
        $username = $f->getElementValue('username');
        Session::checkCredentials($username, $f->getElementValue('password'));
        setcookie('mylocation', Session::getUseR()->getData('location'));
        redirect('index.php', 'You have logged in.');
    } catch (IncorrectPasswordException $e) {
        Logger::messageNormal('Failed login for ' . $username . ', password wrong.', LocalEventType::LOGIN_FAILURE_PASSWORD);
        $f->setElementError('password', 'Password wrong.');
    } catch (UserNotFoundException $e) {
        Logger::messageNormal('Failed login for ' . $username . ', nonexistant user.', LocalEventType::LOGIN_FAILURE_USERNAME);
        $f->setElementError('username', 'User not found');
    }
} else {
    if (isset($_GET['formLogin-username'])) {
        $username = htmlentities($_GET['formLogin-username']);
        $f->getElement('username')->setValue($username);
    }
}
if (Session::isLoggedIn()) {
    redirect('index.php', 'You are already logged in!');
Example #8
0
*******************************************************************************/
require_once 'includes/common.php';
use libAllure\ElementInput;
use libAllure\ElementPassword;
use libAllure\Session;
class FormLogin extends \libAllure\Form
{
    public function __construct()
    {
        $this->addElement(new ElementInput('username', 'Username'));
        $this->addElement(new ElementPassword('password', 'Password'));
        $this->addDefaultButtons();
    }
}
$f = new FormLogin();
if ($f->validate()) {
    $username = $f->getElementValue('username');
    $password = $f->getElementValue('password');
    try {
        //Session::isLoggedIn();
        Session::checkCredentials($username, $password);
        require_once 'includes/widgets/header.minimal.php';
        $core->redirect('index.php', 'Thanks for logging in.');
    } catch (UserNotFoundException $e) {
        $f->setElementError('username', 'User not found');
    } catch (IncorrectPasswordException $e) {
        $f->setElementError('password', 'Incorrect password.');
    }
}
$title = "login";
Example #9
0
 public function loginStepTwoAction()
 {
     $account = Cible_FunctionsGeneral::getAuthentication();
     if (is_null($account)) {
         $path = Zend_Registry::get('web_root') . '/';
         setcookie('returnUrl', $this->view->selectedPage, 0, $path);
         $path = Zend_Registry::get('web_root') . '/';
         $url = $this->view->selectedPage . '/resume-order/';
         setcookie('returnUrl', $url, 0, $path);
         $form = new FormLogin();
         if ($this->_request->isPost() && array_key_exists('submit_login', $_POST)) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $result = Cible_FunctionsGeneral::authenticate($formData['email'], $formData['password']);
                 if ($result['success'] == 'true') {
                     $this->disableView();
                     $hash = md5(session_id());
                     $duration = $formData['stayOn'] ? time() + 60 * 60 * 24 * 365 : 0;
                     $cookie = array('lastName' => utf8_encode($result['lastName']), 'firstName' => utf8_encode($result['firstName']), 'email' => $result['email'], 'hash' => $hash);
                     setcookie("authentication", json_encode($cookie), $duration, $path);
                     $memberProfile = new MemberProfile();
                     $memberProfile->updateMember($result['member_id'], array('hash' => $hash));
                     $this->_redirect($url);
                 } else {
                     $error = Cible_Translation::getClientText('login_form_auth_fail_error');
                     $this->view->assign('error', $error);
                 }
             }
         }
         $this->view->assign('form', $form);
     }
 }