summaryrefslogtreecommitdiff
path: root/login.php
blob: d3101632e2e0c829c563c50106e7a8af9a346a90 (plain)
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
<?php
namespace mcoop;

//$logout = true;

require_once("recaptcha/autoload.php");
require_once("vendor/autoload.php");
require_once("common/config.php");

$danger_alerts = array();
$success_alerts = array();

$login_attempted = false;
if (isset($_POST["username"], $_POST["passwd"])) {
	$login_attempted = true;
	try {
		$db->login($_POST["username"], $_POST["passwd"], $sess_info);
		$success_alerts[] = 'Successfully logged in, <a href="/">Continue</a>';
	} catch (UnknownMember $e) {
		$danger_alerts[] = "Failed to login, no such user";
	} catch (LoginError $e) {
		$danger_alerts[] = "Failed to login, {$e->getMessage()}";
	}
}

echo $twig->render("login.tmpl", array(
	"danger_alerts" => $danger_alerts,
	"success_alerts" => $success_alerts,
	"sess_info" => $sess_info
));

?>