git.cweiske.de
/
phorkie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
display success flash message after forking
[phorkie.git]
/
www
/
login.php
diff --git
a/www/login.php
b/www/login.php
index a2cf97c211ebcaa69fc5fe5fa85b927ffa9da9c6..e141b65b4e8eeeff0bd667cd48d7a5a505cfb86b 100644
(file)
--- a/
www/login.php
+++ b/
www/login.php
@@
-6,12
+6,18
@@
require_once 'www-header.php';
if (isset($_REQUEST['logout'])) {
unset($_SESSION);
session_destroy();
if (isset($_REQUEST['logout'])) {
unset($_SESSION);
session_destroy();
- header('Location: ' . Tools::fullUrl(
'/'
));
+ header('Location: ' . Tools::fullUrl());
exit();
}
if (!count($_GET) && !count($_POST)) {
exit();
}
if (!count($_GET) && !count($_POST)) {
- render('login');
+ render(
+ 'login',
+ array(
+ 'openid' => isset($_COOKIE['lastopenid'])
+ ? $_COOKIE['lastopenid'] : 'http://'
+ )
+ );
exit();
}
exit();
}
@@
-28,17
+34,13
@@
if (isset($_POST['openid_url'])) {
$openid_url = null;
}
$openid_url = null;
}
-$realm = Tools::fullUrl(
'/'
);
-$returnTo = Tools::fullUrl('
/
login');
+$realm = Tools::fullUrl();
+$returnTo = Tools::fullUrl('login');
try {
$o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url);
} catch (OpenID_Exception $e) {
try {
$o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url);
} catch (OpenID_Exception $e) {
- $contents = "<div class='openid_results'>\n";
- $contents .= "<pre>" . $e->getMessage() . "</pre>\n";
- $contents .= "</div class='openid_results'>";
- include_once 'openid/wrapper.php';
- exit;
+ throw new Exception($e->getMessage());
}
if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) {
}
if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) {
@@
-46,20
+48,13
@@
if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associat
$_SESSION['disable_associations'] = true;
}
$_SESSION['disable_associations'] = true;
}
-$log = new \OpenID_Observer_Log;
-\OpenID::attach($log);
-
if (isset($_POST['openid_url'])) {
$_SESSION['openid_url'] = $openid_url;
try {
$authRequest = $o->prepare();
} catch (OpenID_Exception $e) {
if (isset($_POST['openid_url'])) {
$_SESSION['openid_url'] = $openid_url;
try {
$authRequest = $o->prepare();
} catch (OpenID_Exception $e) {
- $contents = "<div class='openid_results'>\n";
- $contents .= "<pre>" . $e->getMessage() . "</pre>\n";
- $contents .= "</div class='openid_results'>";
- include_once 'openid/wrapper.php';
- exit;
+ throw new Exception($e->getMessage());
}
// SREG
}
// SREG
@@
-67,17
+62,18
@@
if (isset($_POST['openid_url'])) {
$sreg->set('required', 'email,fullname');
$authRequest->addExtension($sreg);
$sreg->set('required', 'email,fullname');
$authRequest->addExtension($sreg);
- // AX
+ // AX
, http://stackoverflow.com/a/7657061/282601
$ax = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST);
$ax->set('type.email', 'http://axschema.org/contact/email');
$ax->set('type.firstname', 'http://axschema.org/namePerson/first');
$ax->set('type.lastname', 'http://axschema.org/namePerson/last');
$ax = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST);
$ax->set('type.email', 'http://axschema.org/contact/email');
$ax->set('type.firstname', 'http://axschema.org/namePerson/first');
$ax->set('type.lastname', 'http://axschema.org/namePerson/last');
+ $ax->set('type.fullname', 'http://axschema.org/namePerson');
$ax->set('mode', 'fetch_request');
$ax->set('mode', 'fetch_request');
- $ax->set('required', 'email,firstname,lastname');
+ $ax->set('required', 'email,firstname,lastname
,fullname
');
$authRequest->addExtension($ax);
$url = $authRequest->getAuthorizeURL();
$authRequest->addExtension($ax);
$url = $authRequest->getAuthorizeURL();
-
+
header("Location: $url");
exit;
header("Location: $url");
exit;
@@
-110,13
+106,15
@@
try {
$status = "<tr><td>Status:</td><td><font color='green'>SUCCESS!";
$status .= " ({$result->getAssertionMethod()})</font></td></tr>";
} else {
$status = "<tr><td>Status:</td><td><font color='green'>SUCCESS!";
$status .= " ({$result->getAssertionMethod()})</font></td></tr>";
} else {
+ throw new Exception('Error logging in');
$status = "<tr><td>Status:</td><td><font color='red'>FAIL!";
$status .= " ({$result->getAssertionMethod()})</font></td></tr>";
}
} catch (OpenID_Exception $e) {
$status = "<tr><td>Status:</td><td><font color='red'>FAIL!";
$status .= " ({$result->getAssertionMethod()})</font></td></tr>";
}
} catch (OpenID_Exception $e) {
+ throw new Exception('Error logging in');
$status = "<tr><td>Status:</td><td><font color='red'>EXCEPTION!";
$status .= " ({$e->getMessage()} : {$e->getCode()})</font></td></tr>";
$status = "<tr><td>Status:</td><td><font color='red'>EXCEPTION!";
$status .= " ({$e->getMessage()} : {$e->getCode()})</font></td></tr>";
-
}
+}
$openid = $message->getArrayFormat();
$openid = $message->getArrayFormat();
@@
-130,7
+128,10
@@
$email = isset($openid['openid.ext2.value.email']) && !isset($email)
$email = isset($openid['openid.sreg.email']) && !isset($email)
? $openid['openid.sreg.email']
: $email;
$email = isset($openid['openid.sreg.email']) && !isset($email)
? $openid['openid.sreg.email']
: $email;
-$email = isset($openid['openid.ax.value.email']) && !isset($email)
+$email = isset($openid['openid.ax.value.email'])
+ && isset($openid['openid.ax.type.email'])
+ && $openid['openid.ax.type.email'] == 'http://axschema.org/contact/email'
+ && !isset($email)
? $openid['openid.ax.value.email']
: $email;
$_SESSION['email'] = isset($email)
? $openid['openid.ax.value.email']
: $email;
$_SESSION['email'] = isset($email)
@@
-145,11
+146,23
@@
$name = isset($openid['openid.ext1.value.firstname'])
$name = isset($openid['openid.sreg.fullname']) && !isset($name)
? $openid['openid.sreg.fullname']
: $name;
$name = isset($openid['openid.sreg.fullname']) && !isset($name)
? $openid['openid.sreg.fullname']
: $name;
+$name = isset($openid['openid.ax.value.fullname'])
+ && isset($openid['openid.ax.type.fullname'])
+ && $openid['openid.ax.type.fullname'] == 'http://axschema.org/namePerson'
+ && !isset($name)
+ ? $openid['openid.ax.value.fullname']
+ : $name;
$_SESSION['name'] = isset($name) ? $name : $_SERVER['REMOTE_ADDR'];
$_SESSION['identity'] = $openid['openid.identity'];
$_SESSION['name'] = isset($name) ? $name : $_SERVER['REMOTE_ADDR'];
$_SESSION['identity'] = $openid['openid.identity'];
-$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SESSION['REQUEST_URI'];
+setcookie('lastopenid', $_SESSION['identity'], time() + 84600 * 60, '/login');
+
+$url = '';
+if (isset($_SESSION['REQUEST_URI'])) {
+ $url = substr($_SESSION['REQUEST_URI'], 1);
+}
+$redirect = Tools::fullUrl($url);
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
exit;
?>
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
exit;
?>