blob: 97cd51d96d170464726670016ec45bc6ef966e0e (
plain) (
blame)
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
43
|
<?php
class Page_Session extends Page
{
protected function doPreprocess()
{
if (!isset($_REQUEST['action'])) Util::traceError('No action on module init');
User::load();
if (isset($_POST['action']) && $_POST['action'] === 'login') {
// Login - see if already logged in
if (User::isLoggedIn()) {
Util::redirect('?do=Main');
}
// Else, try to log in
if (User::login($_POST['user'], $_POST['pass'])) {
Util::redirect('?do=Main');
}
// Login credentials wrong
Message::addError('loginfail');
}
if ($_REQUEST['action'] === 'logout') {
if (Util::verifyToken()) {
// Log user out (or do nothing if not logged in)
User::logout();
Util::redirect('?do=Main');
}
}
}
protected function doRender()
{
if ($_REQUEST['action'] === 'login') {
Render::setTitle(Dictionary::translate('lang_login'));
Render::addTemplate('page-login');
return;
}
}
}
|