summaryrefslogtreecommitdiffstats
path: root/modules/session.inc.php
blob: 5b9bc7fc21f3d3a0149514a7297d79ad476c1d1e (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
<?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::setTitle(Dictionary::translate('lang_login'));
		Render::addTemplate('page-login');
	}

}