-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImbaAuth.php
More file actions
82 lines (71 loc) · 2.67 KB
/
ImbaAuth.php
File metadata and controls
82 lines (71 loc) · 2.67 KB
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
72
73
74
75
76
77
78
79
80
81
82
<?php
// Load Dependencies
require_once 'ImbaConstants.php';
require_once 'Shared/Include.php';
require_once 'Model/Include.php';
require_once 'Controller/Include.php';
header('Access-Control-Allow-Origin: *');
// Start the php session
session_set_cookie_params(3600);
session_start();
// Logout has highest prio
if ($_REQUEST["logout"] == true) {
ImbaAuthBase::logout();
} elseif (!empty($_REQUEST["unlock"])) {
/*
$this->manageruser
if ($_REQUEST["key"]) {
}
*/
$msg = "Account unlock with key: " . $_REQUEST["key"];
$this->writeAuthLog($msg);
$this->redirectTo(__LINE__, ImbaSharedFunctions::getTrustRoot(), $msg);
exit();
} elseif (!ImbaUserContext::getLoggedIn()) {
// We are NOT logged in
// Save our referer to session if there is none safed till now
if ($_REQUEST['imbaSsoOpenIdLoginReferer'] != "") {
ImbaUserContext::setRedirectUrl($_REQUEST['imbaSsoOpenIdLoginReferer']);
} else {
if (ImbaUserContext::getRedirectUrl() == "") {
ImbaUserContext::setRedirectUrl($_SERVER['HTTP_REFERER']);
}
}
// Determine Authentication method
switch ($_REQUEST["authMethod"]) {
case "openId":
// OpenID Authentification
$this->redirectTo(__LINE__, $tmpUrl, $this->writeAuthLog("OpenId not supported at the moment!"));
break;
case "password":
// Password Authentification
$tmp = new ImbaAuthPassword();
$tmp->process();
break;
default:
// Send the User to the registration page
if (empty($_SERVER['HTTP_REFERER'])) {
$tmpUrl = ImbaSharedFunctions::getTrustRoot();
} else {
$tmpUrl = $_SERVER['HTTP_REFERER'];
}
$this->redirectTo(__LINE__, $tmpUrl, $this->writeAuthLog("Authentificationmethod not found"));
exit;
}
$this->redirectTo(__LINE__, ImbaUserContext::getRedirectUrl(), $tmpMsg);
exit;
} else {
/**
* we are already logged in! everithing is ok, we have a
* running session and we are going to have a party here!
* - set cookie with logged in openid for autofill login box
* - redirect back to page
*/
ImbaUserContext::setWaitingForVerify("");
$this->writeAuthLog("Already logged in with id: " . ImbaUserContext::getUserId() . ")", 1);
$this->redirectTo(__LINE__, ImbaUserContext::getWaitingForVerify(), ImbaUserContext::setWaitingForVerify(""));
exit;
}
$this->redirectTo(__LINE__, ImbaUserContext::getRedirectUrl(), "We should never have gone so far...");
exit;
?>