Skip to content
Permalink
Newer
Older
100644 25 lines (19 sloc) 637 Bytes
1
<?php
2
defined('APP_DIR') or define('APP_DIR', __DIR__ . '/../app/');
3
include_once(APP_DIR . 'controller/UserController.php');
4
include_once(APP_DIR . 'include/http.php');
5
6
$attempts = User::get(Http::post_params()['username'])->login_attempts;
7
8
if ($attempts >= 8) {
9
Http::redirect('index.php', ['error' => '2']);
10
}
11
12
$user = UserController::authenticate(Http::post_params());
13
14
if (!$user) {
15
Http::redirect('index.php', ['error' => '1']);
16
}
17
18
setcookie(Config::cookie_name, $user->token());
19
if ($user->access == 'user') {
20
Http::redirect('user.php');
21
} else if ($user->access == 'admin') {
22
Http::redirect('admin.php');
23
}
24
25
?>
You can’t perform that action at this time.