smooth a few rough edges of openid

This commit is contained in:
Friendika 2010-11-18 15:06:33 -08:00
parent abc6199c17
commit 0c7ae3aeee
5 changed files with 61 additions and 28 deletions

View file

@ -70,25 +70,52 @@ 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';
// existing account
goaway($openid->authUrl());
// NOTREACHED
}
else {
$a = get_app();
notice( t('Login failed.') . EOL);
goaway($a->get_baseurl());
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 );

View file

@ -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;

View file

@ -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>

View file

@ -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>

View file

@ -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 {