-
Notifications
You must be signed in to change notification settings - Fork 12
/
auth.php
50 lines (45 loc) · 1.19 KB
/
auth.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
<?php
require_once($CFG->libdir.'/authlib.php');
class auth_plugin_loginlogoutredir extends auth_plugin_base {
/**
* Constructor.
*/
function __construct() {
$this->authtype = 'loginlogoutredir';
$this->config = get_config('auth/loginlogoutredir');
}
/*
* Must override or an error is printed.
* @return boolean False means login was not a success.
*/
function user_login($username, $password) {
false;
}
function user_authenticated_hook(&$user, $username, $password) {
global $CFG, $SESSION;
if (isset($CFG->loginredir) && $CFG->loginredir) {
$urltogo = $CFG->loginredir;
if (true || !isset($SESSION->wantsurl)) {
$SESSION->wantsurl = $urltogo;
}
else {
error_log("Not redirecting to '$urltogo': came from other page '$SESSION->wantsurl'");
}
}
else {
error_log("'loginredir' not set in config.php. Not redirecting.");
}
return true;
}
function logoutpage_hook() {
global $CFG;
global $redirect;
if (isset($CFG->logoutredir) && $CFG->logoutredir) {
$redirect = $CFG->logoutredir;
}
else {
error_log("'logoutredir' not set in config.php. Not redirecting.");
}
}
}
?>