/**
  * check administrator authentication
  * role: administrator
  */
 public function login()
 {
     if (Authenticate::is_authorized()) {
         transport("dashboard");
     } else {
         $model_administrator = new Authenticate();
         /*
          * populate login data for administrator
          * use setter method to registering information of authentication
          */
         $model_administrator->set_email($_POST['username']);
         $model_administrator->set_password($_POST['password']);
         $model_administrator->set_type(Authenticate::SUPERUSER);
         $login = $model_administrator->authenticate();
         /*
          * $login variable contain array which have 2 keys [granted] and [state]
          * granted {true|false} and state {active|pending}
          * just grant credential that return active and match email and password
          */
         if ($login["granted"] && $login["state"] == User::ACTIVE) {
             transport("dashboard");
         } else {
             $_SESSION['operation'] = 'error';
             $_SESSION['message'] = $login["state"];
             transport("administrator");
         }
     }
 }
예제 #2
0
파일: index.php 프로젝트: druus/oscar
    $DBSERVER = $settings['database']['host'];
    $DBDRIVER = $settings['database']['driver'];
} else {
    $template = $twig->loadTemplate('error.tmpl');
    echo $template->render(array('pageTitle' => "OSCAR - ERROR", 'error' => "Unable to open the configuration file 'config/config.ini.php'"));
    // No point in continuing, kill ourself
    die;
}
/**
 * Check if the user is logged in or not
 */
//$priv = authenticate();
$priv = false;
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
    $auth = new Authenticate();
    $priv = $auth->authenticate($_SESSION['username'], $_SESSION['password']);
}
/**
 * Test to load data before the asset form is displayed in preparation of using templates
 *
 * N O T E : Added 2016-07-22
 *           The following will be phased out as the class Utilities will be replaced
 *           by Asset and DbHandler...
 */
include_once "classes/Utilities.class.php";
$utilDb = mysqli_connect($DBSERVER, $DBUSER, $DBPASSWD, $DBNAME);
if ($utilDb->connect_error) {
    echo "Database connection failed: " . $utilDb->connect_error;
} else {
    $utils = new Utilities($utilDb);
    //$assetCnt  = $utils->getCount();
include_once $_SERVER['DOCUMENT_ROOT'] . 'hostelManagement/config.php';
if ($_SERVER["REQUEST_METHOD"] != 'POST') {
    include_once ROOT_DIR . "view/error/error_top.php";
    echo 'Your connection is NOT SECURE<br>Ensure you are connected safely';
    include_once ROOT_DIR . "view/error/error_bottom.php";
} else {
    $login_type = $_POST["user-type"];
    if ($login_type == "student") {
        include_once ROOT_DIR . "user/student/controller/authenticate.php";
        $loginStudent = new Authenticate();
        $loginStudent->authenticate();
    } else {
        if ($login_type == "owner") {
            include_once ROOT_DIR . "user/owner/controller/authenticate.php";
            $loginOwner = new Authenticate();
            $loginOwner->authenticate();
        } else {
            if ($login_type == "admin") {
                include_once ROOT_DIR . "user/owner/controller/authenticate.php";
                $loginAdmin = new Authenticate();
                $loginAdmin->authenticate();
            } else {
                include_once ROOT_DIR . "view/error/error_top.php";
                echo 'Something went wrong<br>Please Contact us';
                include_once ROOT_DIR . "view/error/error_bottom.php";
            }
        }
    }
}
?>