Merge commit 'jeff-themovie/0.8.x-openid-enabled' into 0.8.x

This commit is contained in:
Craig Andrews 2009-08-16 19:50:37 -04:00
commit 136a69a387
10 changed files with 60 additions and 13 deletions

8
README
View File

@ -1169,6 +1169,14 @@ For configuring invites.
enabled: Whether to allow users to send invites. Default true. enabled: Whether to allow users to send invites. Default true.
openid
------
For configuring OpenID.
enabled: Whether to allow users to register and login using OpenID. Default
true.
tag tag
--- ---

View File

@ -30,7 +30,9 @@ class FinishopenidloginAction extends Action
function handle($args) function handle($args)
{ {
parent::handle($args); parent::handle($args);
if (common_is_real_login()) { if (!common_config('openid', 'enabled')) {
common_redirect(common_local_url('login'));
} else if (common_is_real_login()) {
$this->clientError(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token'); $token = $this->trimmed('token');

View File

@ -251,11 +251,15 @@ class LoginAction extends Action
return _('For security reasons, please re-enter your ' . return _('For security reasons, please re-enter your ' .
'user name and password ' . 'user name and password ' .
'before changing your settings.'); 'before changing your settings.');
} else { } else if (common_config('openid', 'enabled')) {
return _('Login with your username and password. ' . return _('Login with your username and password. ' .
'Don\'t have a username yet? ' . 'Don\'t have a username yet? ' .
'[Register](%%action.register%%) a new account, or ' . '[Register](%%action.register%%) a new account, or ' .
'try [OpenID](%%action.openidlogin%%). '); 'try [OpenID](%%action.openidlogin%%). ');
} else {
return _('Login with your username and password. ' .
'Don\'t have a username yet? ' .
'[Register](%%action.register%%) a new account.');
} }
} }

View File

@ -26,7 +26,9 @@ class OpenidloginAction extends Action
function handle($args) function handle($args)
{ {
parent::handle($args); parent::handle($args);
if (common_is_real_login()) { if (!common_config('openid', 'enabled')) {
common_redirect(common_local_url('login'));
} else if (common_is_real_login()) {
$this->clientError(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$openid_url = $this->trimmed('openid_url'); $openid_url = $this->trimmed('openid_url');

View File

@ -82,6 +82,12 @@ class OpenidsettingsAction extends AccountSettingsAction
function showContent() function showContent()
{ {
if (!common_config('openid', 'enabled')) {
$this->element('div', array('class' => 'error'),
_('OpenID is not available.'));
return;
}
$user = common_current_user(); $user = common_current_user();
$this->elementStart('form', array('method' => 'post', $this->elementStart('form', array('method' => 'post',

View File

@ -329,14 +329,22 @@ class RegisterAction extends Action
} else if ($this->error) { } else if ($this->error) {
$this->element('p', 'error', $this->error); $this->element('p', 'error', $this->error);
} else { } else {
$instr = if (common_config('openid', 'enabled')) {
common_markup_to_html(_('With this form you can create '. $instr =
' a new account. ' . common_markup_to_html(_('With this form you can create '.
'You can then post notices and '. ' a new account. ' .
'link up to friends and colleagues. '. 'You can then post notices and '.
'(Have an [OpenID](http://openid.net/)? ' . 'link up to friends and colleagues. '.
'Try our [OpenID registration]'. '(Have an [OpenID](http://openid.net/)? ' .
'(%%action.openidlogin%%)!)')); 'Try our [OpenID registration]'.
'(%%action.openidlogin%%)!)'));
} else {
$instr =
common_markup_to_html(_('With this form you can create '.
' a new account. ' .
'You can then post notices and '.
'link up to friends and colleagues.'));
}
$this->elementStart('div', 'instructions'); $this->elementStart('div', 'instructions');
$this->raw($instr); $this->raw($instr);

View File

@ -99,6 +99,9 @@ $config['sphinx']['port'] = 3312;
// $config['xmpp']['public'][] = 'someindexer@example.net'; // $config['xmpp']['public'][] = 'someindexer@example.net';
// $config['xmpp']['debug'] = false; // $config['xmpp']['debug'] = false;
// Disable OpenID
// $config['openid']['enabled'] = false;
// Turn off invites // Turn off invites
// $config['invite']['enabled'] = false; // $config['invite']['enabled'] = false;

View File

@ -126,6 +126,10 @@ class AccountSettingsNav extends Widget
$this->action->elementStart('ul', array('class' => 'nav')); $this->action->elementStart('ul', array('class' => 'nav'));
foreach ($menu as $menuaction => $menudesc) { foreach ($menu as $menuaction => $menudesc) {
if ($menuaction == 'openidsettings' &&
!common_config('openid', 'enabled')) {
continue;
}
$this->action->menuItem(common_local_url($menuaction), $this->action->menuItem(common_local_url($menuaction),
$menudesc[0], $menudesc[0],
$menudesc[1], $menudesc[1],

View File

@ -170,6 +170,8 @@ $config =
'host' => null, # only set if != server 'host' => null, # only set if != server
'debug' => false, # print extra debug info 'debug' => false, # print extra debug info
'public' => array()), # JIDs of users who want to receive the public stream 'public' => array()), # JIDs of users who want to receive the public stream
'openid' =>
array('enabled' => true),
'invite' => 'invite' =>
array('enabled' => true), array('enabled' => true),
'sphinx' => 'sphinx' =>
@ -371,6 +373,12 @@ if ($_db_name != 'laconica' && !array_key_exists('ini_'.$_db_name, $config['db']
$config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/laconica.ini'; $config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/laconica.ini';
} }
// Ignore openidonly if OpenID is disabled
if (!$config['openid']['enabled']) {
$config['site']['openidonly'] = false;
}
// XXX: how many of these could be auto-loaded on use? // XXX: how many of these could be auto-loaded on use?
require_once 'Validate.php'; require_once 'Validate.php';

View File

@ -80,8 +80,10 @@ class LoginGroupNav extends Widget
_('Sign up for a new account')); _('Sign up for a new account'));
} }
} }
$menu['openidlogin'] = array(_('OpenID'), if (common_config('openid', 'enabled')) {
_('Login or register with OpenID')); $menu['openidlogin'] = array(_('OpenID'),
_('Login or register with OpenID'));
}
$action_name = $this->action->trimmed('action'); $action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav')); $this->action->elementStart('ul', array('class' => 'nav'));