Subversion-Projekte lars-tiefland.ci

Revision

Revision 2406 | Revision 2408 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

/**
 *
 * @package WebanOS CI
 * @author Lars Tiefland <ltiefland@gmail.com> 
 * @copyright 2016
 * @version $Rev: 2407 $
 */

class Login extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Login_model', 'login');
    }
    public function index()
    {
        $this->login_form();
    }

    function execute()
    {
        if ($this->form_validation->run() === false) {
            $this->login_form();
        } else {
            $res = $this->login->check_user();
            if (!$res) {
                $this->login_form();
            } else {
                $this->session->username = $this->input->post('user');
                $this->session->user_data = $res;
                header("Location:/backend/");
            }
        }
    }

    private function login_form()
    {
        $data["errors"] = validation_errors();
        $data["title"] = "Anmeldung";
        $this->smarty->view('login.tpl', $data);
    }

    public function logout()
    {
        $this->session->clicked = null;
        $this->session->clicked_tool = null;
        $this->session->filter = null;
        unset($_SESSION["username"]);
        unset($_SESSION["user_data"]);
        unset($_SESSION["redirected"]);
        header("Location:/backend/");
    }
}

?>