diff --git a/include/auth.php b/include/auth.php index c09a89ffb3..0a6050a17e 100644 --- a/include/auth.php +++ b/include/auth.php @@ -70,27 +70,54 @@ 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']); - $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'; - goaway($openid->authUrl()); - // NOTREACHED - } - else { + 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)) { + // existing account + goaway($openid->authUrl()); + // NOTREACHED + } + else { + 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 + } } } if((x($_POST,'auth-params')) && $_POST['auth-params'] === 'login') { @@ -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 ); diff --git a/mod/home.php b/mod/home.php index 13b6d56c4a..b8f16158eb 100644 --- a/mod/home.php +++ b/mod/home.php @@ -20,6 +20,7 @@ function home_content(&$a) { $o .= '

Welcome' . ((x($a->config,'sitename')) ? " to {$a->config['sitename']}" : "" ) . '

'; if(file_exists('home.html')) $o .= file_get_contents('home.html'); + $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); return $o; diff --git a/view/en/login.tpl b/view/en/login.tpl index 8fe09e7d37..396a00266f 100644 --- a/view/en/login.tpl +++ b/view/en/login.tpl @@ -2,12 +2,12 @@
- - + +
- +
diff --git a/view/en/settings.tpl b/view/en/settings.tpl index f1926c004c..734effc0c2 100644 --- a/view/en/settings.tpl +++ b/view/en/settings.tpl @@ -128,8 +128,8 @@ Leave password fields blank unless changing
- - + + (Optional) Allow this OpenID to login to this account.
diff --git a/view/theme/default/style.css b/view/theme/default/style.css index bd2e418496..ee73cd114c 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -379,19 +379,24 @@ footer { #label-login-name, #label-login-password, #login-extra-filler { float: left; - width: 150px; + width: 200px; margin-bottom: 20px; } -#login-name, #login-password { +#login-password { + float: left; + width: 170px; +} + +#login-name { float: left; width: 150px; } #register-link, #lost-password-link { float: left; - font-size: 0.7em; + font-size: 80%; margin-right: 15px; } @@ -400,8 +405,8 @@ footer { } #login-submit-button { - margin-top: 10px; - margin-left: 150px; +/* margin-top: 10px; */ + margin-left: 200px; } input#dfrn-url {