aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2010-11-18 15:06:33 -0800
committerFriendika <info@friendika.com>2010-11-18 15:06:33 -0800
commit0c7ae3aeee155425c0e2928ae67df76a7d1fe61e (patch)
tree66f907f8899f588ed42c0d9c01711c93cbe34dd9 /include
parentabc6199c175986c6d3f7b8b7944f1c3c1ec26163 (diff)
downloadvolse-hubzilla-0c7ae3aeee155425c0e2928ae67df76a7d1fe61e.tar.gz
volse-hubzilla-0c7ae3aeee155425c0e2928ae67df76a7d1fe61e.tar.bz2
volse-hubzilla-0c7ae3aeee155425c0e2928ae67df76a7d1fe61e.zip
smooth a few rough edges of openid
Diffstat (limited to 'include')
-rw-r--r--include/auth.php57
1 files changed, 42 insertions, 15 deletions
diff --git a/include/auth.php b/include/auth.php
index c09a89ffb..0a6050a17 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -70,26 +70,53 @@ else {
if((x($_POST,'password')) && strlen($_POST['password']))
$encrypted = hash('whirlpool',trim($_POST['password']));
else {
- if((x($_POST,'login-name')) && strlen($_POST['login-name'])) {
- $openid_url = trim($_POST['login-name']);
+ if((x($_POST,'openid_url')) && strlen($_POST['openid_url'])) {
+
+ $openid_url = trim($_POST['openid_url']);
+
+ // validate_url alters the calling parameter
+
+ $temp_string = $openid_url;
+
+ // if it's an email address or doesn't resolve to a URL, fail.
+
+ if((strpos($temp_string,'@')) || (! validate_url($temp_string))) {
+ $a = get_app();
+ notice( t('Login failed.') . EOL);
+ goaway($a->get_baseurl());
+ // NOTREACHED
+ }
+
+ // Otherwise it's probably an openid.
+
+ require_once('library/openid.php');
+ $openid = new LightOpenID;
+ $openid->identity = $openid_url;
+ $_SESSION['openid'] = $openid_url;
+ $a = get_app();
+ $openid->returnUrl = $a->get_baseurl() . '/openid';
+
$r = q("SELECT `uid` FROM `user` WHERE `openid` = '%s' LIMIT 1",
dbesc($openid_url)
);
- if(count($r)) {
- require_once('library/openid.php');
- $openid = new LightOpenID;
- $openid->identity = $openid_url;
- $_SESSION['openid'] = $openid_url;
- $a = get_app();
- $openid->returnUrl = $a->get_baseurl() . '/openid';
+ if(count($r)) {
+ // existing account
goaway($openid->authUrl());
// NOTREACHED
}
else {
- $a = get_app();
- notice( t('Login failed.') . EOL);
- goaway($a->get_baseurl());
- // NOTREACHED
+ if($a->config['register_policy'] == REGISTER_CLOSED) {
+ $a = get_app();
+ notice( t('Login failed.') . EOL);
+ goaway($a->get_baseurl());
+ // NOTREACHED
+ }
+ // new account
+ $_SESSION['register'] = 1;
+ $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
+ $openid->optional = array('namePerson/first');
+ goaway($openid->authUrl());
+ // NOTREACHED
}
}
}
@@ -99,8 +126,8 @@ else {
$r = q("SELECT * FROM `user`
WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
- dbesc(trim($_POST['login-name'])),
- dbesc(trim($_POST['login-name'])),
+ dbesc(trim($_POST['openid_url'])),
+ dbesc(trim($_POST['openid_url'])),
dbesc($encrypted));
if(($r === false) || (! count($r))) {
notice( t('Login failed.') . EOL );