-
Notifications
You must be signed in to change notification settings - Fork 24
/
login.php
71 lines (52 loc) · 1.59 KB
/
login.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once(__DIR__ . '/global.php');
require_once(__DIR__ . '/classes/User.php');
// Allow modules to auto-login (if supported)
$user = null;
foreach (UserConfig::$authentication_modules as $module) {
$user = $module->processAutoLogin();
if (!is_null($user)) {
$remember = false;
$user->setSession($remember);
$return = User::getReturn();
User::clearReturn();
if (!is_null($return)) {
header('Location: ' . $return);
} else {
header('Location: ' . UserConfig::$DEFAULTLOGINRETURN);
}
exit;
}
}
if (array_key_exists('login', $_POST)) {
$module = null;
foreach (UserConfig::$authentication_modules as $module) {
if ($module->getID() == $_GET['module']) {
break;
}
}
$remember = false;
$user = $module->processLogin($_POST, $remember);
if (is_null($user)) {
header('Location: ' . UserConfig::$USERSROOTURL . '/login.php?module=' . $_GET['module'] . '&error=failed');
exit;
}
$user->setSession($remember);
$return = User::getReturn();
User::clearReturn();
if (!is_null($return)) {
header('Location: ' . $return);
} else {
header('Location: ' . UserConfig::$DEFAULTLOGINRETURN);
}
exit;
}
$template_info = StartupAPI::getTemplateInfo();
foreach (UserConfig::$authentication_modules as $module) {
$id = $module->getID();
$template_info['module_forms'][$id] = $module->renderLoginForm($template_info, "?module=$id");
}
if (array_key_exists('module', $_GET) && $id == $_GET['module'] && array_key_exists('error', $_GET)) {
$template_info['login_failed'][$id] = TRUE;
}
StartupAPI::$template->display('@startupapi/login.html.twig', $template_info);