示例#1
0
if (Config::get('general/environment') == 'development') {
    /**
     *
     * Nice looking and informative error reporting
     *
     **/
    $whoops = new Run();
    $whoops->pushHandler(new PrettyPageHandler());
    $whoops->register();
} else {
    ini_set("display_errors", 0);
}
$loader = new Twig_Loader_Filesystem(APP . 'view');
$options = ['cache' => APP . 'storage/twig', 'auto_reload' => true];
$twig = new Twig_Environment($loader, $options);
header('Content-Type: text/html; charset=UTF-8');
/**
*
* "Remember me" functionality for login system
*
**/
$rememberCookieExists = Cookie::exists(Config::get('cookie_to_remember_employee_session/name'));
$employeeSessionExists = Session::exists(Config::get('session/name'));
if ($rememberCookieExists === true && $employeeSessionExists === false) {
    $hash = Cookie::get(Config::get('cookie_to_remember_employee_session/name'));
    $hashCheck = Database::getInstance()->get('employee_session', ['hash', '=', $hash]);
    if ($hashCheck->count()) {
        $employee = new Employee($hashCheck->first()->employee_id);
        $employee->login();
    }
}
示例#2
0
 public function logEmployeeIn($data)
 {
     $errorHandler = new ErrorHandler();
     $validator = new Validate($errorHandler);
     $validator->check($data, ['email' => ['required' => true], 'password' => ['required' => true]]);
     if ($errorHandler->hasErrors()) {
         $this->errors = $errorHandler->all();
         return false;
     } else {
         $employee = new Employee();
         $login = $employee->login($data['email'], $data['password'], $data['remember']);
         if (!$login) {
             return 'no';
         }
         Session::flash('home', 'You are now logged in.');
         return true;
     }
 }