blob: 853f20e4fa550712c2e5fe6ca10fc6b093a5b23e (
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
|
<?php
class Page_Session extends Page
{
protected function doPreprocess()
{
User::load();
if (Request::post('action') === 'login') {
// Login - see if already logged in
if (User::isLoggedIn()) // and then just redirect
Util::redirect('?do=Main');
// Else, try to log in
if (User::login(Request::post('user'), Request::post('pass')))
Util::redirect('?do=Main');
// Login credentials wrong - delay and show error message
sleep(1);
Message::addError('loginfail');
}
if (Request::post('action') === 'logout') {
// Log user out (or do nothing if not logged in)
User::logout();
Util::redirect('?do=Main');
}
if (User::isLoggedIn())
Util::redirect('?do=Main');
}
protected function doRender()
{
Render::addTemplate('page-login');
}
}
|