smooth a few rough edges of openid
This commit is contained in:
parent
abc6199c17
commit
0c7ae3aeee
|
@ -70,27 +70,54 @@ else {
|
||||||
if((x($_POST,'password')) && strlen($_POST['password']))
|
if((x($_POST,'password')) && strlen($_POST['password']))
|
||||||
$encrypted = hash('whirlpool',trim($_POST['password']));
|
$encrypted = hash('whirlpool',trim($_POST['password']));
|
||||||
else {
|
else {
|
||||||
if((x($_POST,'login-name')) && strlen($_POST['login-name'])) {
|
if((x($_POST,'openid_url')) && strlen($_POST['openid_url'])) {
|
||||||
$openid_url = trim($_POST['login-name']);
|
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE `openid` = '%s' LIMIT 1",
|
$openid_url = trim($_POST['openid_url']);
|
||||||
dbesc($openid_url)
|
|
||||||
);
|
// validate_url alters the calling parameter
|
||||||
if(count($r)) {
|
|
||||||
require_once('library/openid.php');
|
$temp_string = $openid_url;
|
||||||
$openid = new LightOpenID;
|
|
||||||
$openid->identity = $openid_url;
|
// if it's an email address or doesn't resolve to a URL, fail.
|
||||||
$_SESSION['openid'] = $openid_url;
|
|
||||||
$a = get_app();
|
if((strpos($temp_string,'@')) || (! validate_url($temp_string))) {
|
||||||
$openid->returnUrl = $a->get_baseurl() . '/openid';
|
|
||||||
goaway($openid->authUrl());
|
|
||||||
// NOTREACHED
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
notice( t('Login failed.') . EOL);
|
notice( t('Login failed.') . EOL);
|
||||||
goaway($a->get_baseurl());
|
goaway($a->get_baseurl());
|
||||||
// NOTREACHED
|
// 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') {
|
if((x($_POST,'auth-params')) && $_POST['auth-params'] === 'login') {
|
||||||
|
@ -99,8 +126,8 @@ else {
|
||||||
|
|
||||||
$r = q("SELECT * FROM `user`
|
$r = q("SELECT * FROM `user`
|
||||||
WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
|
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['openid_url'])),
|
||||||
dbesc(trim($_POST['login-name'])),
|
dbesc(trim($_POST['openid_url'])),
|
||||||
dbesc($encrypted));
|
dbesc($encrypted));
|
||||||
if(($r === false) || (! count($r))) {
|
if(($r === false) || (! count($r))) {
|
||||||
notice( t('Login failed.') . EOL );
|
notice( t('Login failed.') . EOL );
|
||||||
|
|
|
@ -20,6 +20,7 @@ function home_content(&$a) {
|
||||||
$o .= '<h1>Welcome' . ((x($a->config,'sitename')) ? " to {$a->config['sitename']}" : "" ) . '</h1>';
|
$o .= '<h1>Welcome' . ((x($a->config,'sitename')) ? " to {$a->config['sitename']}" : "" ) . '</h1>';
|
||||||
if(file_exists('home.html'))
|
if(file_exists('home.html'))
|
||||||
$o .= file_get_contents('home.html');
|
$o .= file_get_contents('home.html');
|
||||||
|
|
||||||
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
|
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
<form action="" method="post" >
|
<form action="" method="post" >
|
||||||
<input type="hidden" name="auth-params" value="login" />
|
<input type="hidden" name="auth-params" value="login" />
|
||||||
<div id="login-name-wrapper">
|
<div id="login-name-wrapper">
|
||||||
<label for="login-name" id="label-login-name">Nickname or Email: </label>
|
<label for="login-name" id="label-login-name">Nickname/Email/OpenID: </label>
|
||||||
<input type="text" maxlength="60" name="login-name" id="login-name" value="" />
|
<input type="text" maxlength="60" name="openid_url" class="openid" id="login-name" value="" />
|
||||||
</div>
|
</div>
|
||||||
<div id="login-name-end" ></div>
|
<div id="login-name-end" ></div>
|
||||||
<div id="login-password-wrapper">
|
<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="" />
|
<input type="password" maxlength="60" name="password" id="login-password" value="" />
|
||||||
</div>
|
</div>
|
||||||
<div id="login-password-end"></div>
|
<div id="login-password-end"></div>
|
||||||
|
|
|
@ -128,8 +128,8 @@ Leave password fields blank unless changing
|
||||||
<div id="settings-confirm-end" ></div>
|
<div id="settings-confirm-end" ></div>
|
||||||
|
|
||||||
<div id="settings-openid-wrapper" >
|
<div id="settings-openid-wrapper" >
|
||||||
<label id="settings-openid-label" for="settings-openid" >(optional) OpenID: </label>
|
<label id="settings-openid-label" for="settings-openid" >OpenID: </label>
|
||||||
<input type="text" id="settings-openid" class="openid" name="openid_url" value="$openid" />
|
<input type="text" id="settings-openid" class="openid" name="openid_url" value="$openid" /> (Optional) Allow this OpenID to login to this account.
|
||||||
</div>
|
</div>
|
||||||
<div id="settings-openid-end" ></div>
|
<div id="settings-openid-end" ></div>
|
||||||
|
|
||||||
|
|
|
@ -379,19 +379,24 @@ footer {
|
||||||
|
|
||||||
#label-login-name, #label-login-password, #login-extra-filler {
|
#label-login-name, #label-login-password, #login-extra-filler {
|
||||||
float: left;
|
float: left;
|
||||||
width: 150px;
|
width: 200px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#login-name, #login-password {
|
#login-password {
|
||||||
|
float: left;
|
||||||
|
width: 170px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login-name {
|
||||||
float: left;
|
float: left;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#register-link, #lost-password-link {
|
#register-link, #lost-password-link {
|
||||||
float: left;
|
float: left;
|
||||||
font-size: 0.7em;
|
font-size: 80%;
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,8 +405,8 @@ footer {
|
||||||
}
|
}
|
||||||
|
|
||||||
#login-submit-button {
|
#login-submit-button {
|
||||||
margin-top: 10px;
|
/* margin-top: 10px; */
|
||||||
margin-left: 150px;
|
margin-left: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input#dfrn-url {
|
input#dfrn-url {
|
||||||
|
|
Loading…
Reference in a new issue