/**
     *
     * @todo add openid authentication
     *
     */
    public function loginAction()
    {
        $form = new App_Form_Login();
        if (!empty($_POST) && $form->isValid($_POST)) {
            $username = $form->getValue('username');
            $password = $form->getValue('password');
            //------------------------------------
            // make sure the login form validates
            //------------------------------------
            if ($form->isValid($_POST)) {
                $auth = Zend_Auth::getInstance();
                //------------------------------------------
                // Attempt a standard database login
                //------------------------------------------
                $adapter = new ZendX_Doctrine_Auth_Adapter(Doctrine_Manager::connection(), 'Account', 'username', 'password', 'MD5(?) AND enabled = 1 AND confirmed = 1');
                $adapter->setIdentity($username);
                $adapter->setCredential($password);
                $result = $auth->authenticate($adapter);
                if (!$result->isValid()) {
                    $message = 'The username and password provided does not match our records';
                    $this->_flash->addMessage($message);
                    $form->addError($message);
                } else {
                    $userdata = $adapter->getResultRowObject(null, 'password');
                    //translate the user into an actual doctrine object
                    $accounts = new App_Table_Account();
                    $auth->getStorage()->write($accounts->find($userdata->id));
                    //audit the login
                    $login = new AccountLogin();
                    $login->accountId = $userdata->id;
                    $login->ip = ip2long($_SERVER['REMOTE_ADDR']);
                    $login->save();
                    $this->_flash->addMessage('Welcome back, ' . $result->getIdentity());
                    $this->_redirector->gotoSimple('profile');
                }
            }
        }
        // force users to logout before they can try to login
        if (Zend_Auth::getInstance()->getIdentity() !== null) {
            $this->_flash->addMessage('You are already logged in!  You must log out before you can
				log into a different account.');
            $this->_redirector->gotoSimple('profile');
        }
        $form->setMethod(Zend_Form::METHOD_POST);
        $this->view->form = $form;
    }
 function logout()
 {
     $acc = new AccountLogin();
     $acc->process_logout();
 }
Beispiel #3
0
    function loginpage()
    {
        if (Auth::isLogged()) {
            header("Location:" . _SPPATH . "mydashboard");
            exit;
        }
        //        pr($_COOKIE);
        //        pr($_SESSION);
        ?>
        <style>
            @media (max-width: 768px) {

                .monly {
                    display: initial;
                }

                .donly {
                    display: none;
                }

                .loginbox{
                    margin-top: 50px;
                }


            }

            @media (min-width: 768px) {
                .monly {
                    display: none;
                }

                .donly {
                    display: initial;
                }

                .loginbox{
                    margin-top: 80px;
                }


            }
        </style>
        <div class="container attop" >

        <div class="col-md-4 col-md-offset-4 loginbox " style="text-align: center; ">
            <div style="padding: 20px; padding-bottom: 0px;">
                <img class="animated zoomIn" src="<?php 
        echo _SPPATH;
        ?>
images/appear-text.png" style="max-width: 80%;">
            </div>

            <div class="berpadding">
            <?php 
        $acc = new AccountLogin();
        $acc->loginForm();
        ?>
            <style>
                .checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {
                     margin-left: 0px;
                    display: none;
                }
                .checkboxspan{
                    margin-left: 20px;
                    display: none;
                }
                .btn-primary {
                    color: #fff;
                    background-color: #008247;
                    border-color: #008247;
                }
                .btn-primary:hover,.btn-primary:focus{
                    background-color: #00a157;
                    border-color: #00a157;
                }
                a{
                    color: #005c32;
                    text-decoration: underline;
                }
                a:hover{
                    color: #008d4c;
                }
            </style>
            <div style="margin-top: 10px; text-align: right;color: #005c32;">
<!--                <a class="btn btn-default"  href="--><?php 
        //=_SPPATH;
        ?>
<!--forgotpassword">forgot password</a>-->
                <a  href="<?php 
        echo _SPPATH;
        ?>
register">register</a> <i class="glyphicon glyphicon-option-vertical"></i> <a  href="<?php 
        echo _SPPATH;
        ?>
enquiry">learn more</a> <i class="glyphicon glyphicon-option-vertical"></i> <a  href="<?php 
        echo _SPPATH;
        ?>
forgotpassword">forgot password</a>
            </div>
<!--            <h1 class="hype" style="margin-bottom: 30px;">OR</h1>-->
<!--            <a class="btn btn-lg btn-success btn-block" href="--><?php 
        //=_SPPATH;
        ?>
<!--register">Register</a>-->
<!--            -->

            </div>
        </div>

        <div class="clearfix" ></div>
<!--        <div style="text-align: center; padding-top: 30px;">-->
<!--            Copyright &copy; PT. Indo Mega Byte-->
<!--        </div>-->

        </div>
       <?php 
    }
    function loginpage()
    {
        ?>
<div class="container attop" >
        <div class="col-md-4 col-md-offset-4">
            <h1 class="hype" style="margin-bottom: 30px;">Login</h1>
            <?php 
        $acc = new AccountLogin();
        $acc->loginForm();
        ?>
            <style>
                .checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {

                     margin-left: 0px;
                }
                .checkboxspan{
                    margin-left: 20px;
                }
            </style>
            <div style="margin-top: 10px; text-align: right;">
            <a  href="<?php 
        echo _SPPATH;
        ?>
forgotpassword">Forgot Password</a>
            </div>
            <h1 class="hype" style="margin-bottom: 30px;">OR</h1>
            <a class="btn btn-lg btn-success btn-block" href="<?php 
        echo _SPPATH;
        ?>
register">Register</a>
            </div>

        <div class="clearfix" ></div>
        </div>
       <?php 
    }
 function adminpage()
 {
     $acc = new AccountLogin();
     $acc->loginForm();
 }
 function index()
 {
     $acc = new AccountLogin();
     $acc->loginForm();
 }