aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/auth.php57
-rw-r--r--mod/home.php1
-rw-r--r--view/en/login.tpl6
-rw-r--r--view/en/settings.tpl4
-rw-r--r--view/theme/default/style.css15
5 files changed, 58 insertions, 25 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 );
diff --git a/mod/home.php b/mod/home.php
index 13b6d56c4..b8f16158e 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -20,6 +20,7 @@ function home_content(&$a) {
$o .= '<h1>Welcome' . ((x($a->config,'sitename')) ? " to {$a->config['sitename']}" : "" ) . '</h1>';
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 8fe09e7d3..396a00266 100644
--- a/view/en/login.tpl
+++ b/view/en/login.tpl
@@ -2,12 +2,12 @@
<form action="" method="post" >
<input type="hidden" name="auth-params" value="login" />
<div id="login-name-wrapper">
- <label for="login-name" id="label-login-name">Nickname or Email: </label>
- <input type="text" maxlength="60" name="login-name" id="login-name" value="" />
+ <label for="login-name" id="label-login-name">Nickname/Email/OpenID: </label>
+ <input type="text" maxlength="60" name="openid_url" class="openid" id="login-name" value="" />
</div>
<div id="login-name-end" ></div>
<div id="login-password-wrapper">
- <label for="login-password" id="label-login-password">Password: </label>
+ <label for="login-password" id="label-login-password">Password (if not OpenID): </label>
<input type="password" maxlength="60" name="password" id="login-password" value="" />
</div>
<div id="login-password-end"></div>
diff --git a/view/en/settings.tpl b/view/en/settings.tpl
index f1926c004..734effc0c 100644
--- a/view/en/settings.tpl
+++ b/view/en/settings.tpl
@@ -128,8 +128,8 @@ Leave password fields blank unless changing
<div id="settings-confirm-end" ></div>
<div id="settings-openid-wrapper" >
-<label id="settings-openid-label" for="settings-openid" >(optional) OpenID: </label>
-<input type="text" id="settings-openid" class="openid" name="openid_url" value="$openid" />
+<label id="settings-openid-label" for="settings-openid" >OpenID: </label>
+<input type="text" id="settings-openid" class="openid" name="openid_url" value="$openid" />&nbsp;(Optional) Allow this OpenID to login to this account.
</div>
<div id="settings-openid-end" ></div>
diff --git a/view/theme/default/style.css b/view/theme/default/style.css
index bd2e41849..ee73cd114 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 {