-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.php
executable file
·42 lines (32 loc) · 1.12 KB
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require_once 'protected/core.php';
switch($_SERVER['QUERY_STRING']) {
default:
case 'login':
if(! App::$user->isGuest()) {
App::redirectTo('index.php');
}
if(App::isPost()) {
// Обработать введённые данные
try {
if ($_POST['login'] == '' || $_POST['password'] == '')
App::error('auth','Введите свои учётные данные (имя и пароль)');
$login = $_POST['login'];
$password = $_POST['password'];
if (!App::$user->authenicate($login, $password)) {
App::error('auth', 'Неверное имя пользователя и/или пароль');
}
App::$user->login(isset($_POST['remember']));
} catch(Exception $e) {
App::render('login');
}
} else {
App::render('login');
}
break;
case 'logout':
App::$user->logout();
break;
}
App::redirectTo('index.php');
?>