Added a configuration option to disable OpenID.
If $config['openid']['enabled'] is set to false, OpenID is removed from the navigation and direct accesses to OpenID login pages redirect to the login page. If OpenID is enabled, $config['site']['openidonly'] is ignored, i.e. OpenID is required to go OpenID-only.
This commit is contained in:
parent
853b6d38b3
commit
7dc3a90d12
8
README
8
README
@ -1169,6 +1169,14 @@ For configuring invites.
|
||||
|
||||
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
|
||||
---
|
||||
|
||||
|
@ -30,7 +30,9 @@ class FinishopenidloginAction extends Action
|
||||
function 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.'));
|
||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$token = $this->trimmed('token');
|
||||
|
@ -251,11 +251,15 @@ class LoginAction extends Action
|
||||
return _('For security reasons, please re-enter your ' .
|
||||
'user name and password ' .
|
||||
'before changing your settings.');
|
||||
} else {
|
||||
} else if (common_config('openid', 'enabled')) {
|
||||
return _('Login with your username and password. ' .
|
||||
'Don\'t have a username yet? ' .
|
||||
'[Register](%%action.register%%) a new account, or ' .
|
||||
'try [OpenID](%%action.openidlogin%%). ');
|
||||
} else {
|
||||
return _('Login with your username and password. ' .
|
||||
'Don\'t have a username yet? ' .
|
||||
'[Register](%%action.register%%) a new account.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,9 @@ class OpenidloginAction extends Action
|
||||
function 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.'));
|
||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$openid_url = $this->trimmed('openid_url');
|
||||
|
@ -82,6 +82,12 @@ class OpenidsettingsAction extends AccountSettingsAction
|
||||
|
||||
function showContent()
|
||||
{
|
||||
if (!common_config('openid', 'enabled')) {
|
||||
$this->element('div', array('class' => 'error'),
|
||||
_('OpenID is not available.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
|
@ -329,14 +329,22 @@ class RegisterAction extends Action
|
||||
} else if ($this->error) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
} 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. '.
|
||||
'(Have an [OpenID](http://openid.net/)? ' .
|
||||
'Try our [OpenID registration]'.
|
||||
'(%%action.openidlogin%%)!)'));
|
||||
if (common_config('openid', 'enabled')) {
|
||||
$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. '.
|
||||
'(Have an [OpenID](http://openid.net/)? ' .
|
||||
'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->raw($instr);
|
||||
|
@ -99,6 +99,9 @@ $config['sphinx']['port'] = 3312;
|
||||
// $config['xmpp']['public'][] = 'someindexer@example.net';
|
||||
// $config['xmpp']['debug'] = false;
|
||||
|
||||
// Disable OpenID
|
||||
// $config['openid']['enabled'] = false;
|
||||
|
||||
// Turn off invites
|
||||
// $config['invite']['enabled'] = false;
|
||||
|
||||
|
@ -126,6 +126,10 @@ class AccountSettingsNav extends Widget
|
||||
$this->action->elementStart('ul', array('class' => 'nav'));
|
||||
|
||||
foreach ($menu as $menuaction => $menudesc) {
|
||||
if ($menuaction == 'openidsettings' &&
|
||||
!common_config('openid', 'enabled')) {
|
||||
continue;
|
||||
}
|
||||
$this->action->menuItem(common_local_url($menuaction),
|
||||
$menudesc[0],
|
||||
$menudesc[1],
|
||||
|
@ -443,7 +443,8 @@ class Action extends HTMLOutputter // lawsuit
|
||||
}
|
||||
$this->menuItem(common_local_url('login'),
|
||||
_('Login'), _('Login to the site'), false, 'nav_login');
|
||||
} else {
|
||||
}
|
||||
if (common_config('openid', 'enabled')) {
|
||||
$this->menuItem(common_local_url('openidlogin'),
|
||||
_('OpenID'), _('Login with OpenID'), false, 'nav_openid');
|
||||
}
|
||||
|
@ -170,6 +170,8 @@ $config =
|
||||
'host' => null, # only set if != server
|
||||
'debug' => false, # print extra debug info
|
||||
'public' => array()), # JIDs of users who want to receive the public stream
|
||||
'openid' =>
|
||||
array('enabled' => true),
|
||||
'invite' =>
|
||||
array('enabled' => true),
|
||||
'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';
|
||||
}
|
||||
|
||||
// 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?
|
||||
|
||||
require_once 'Validate.php';
|
||||
|
@ -80,8 +80,10 @@ class LoginGroupNav extends Widget
|
||||
_('Sign up for a new account'));
|
||||
}
|
||||
}
|
||||
$menu['openidlogin'] = array(_('OpenID'),
|
||||
_('Login or register with OpenID'));
|
||||
if (common_config('openid', 'enabled')) {
|
||||
$menu['openidlogin'] = array(_('OpenID'),
|
||||
_('Login or register with OpenID'));
|
||||
}
|
||||
|
||||
$action_name = $this->action->trimmed('action');
|
||||
$this->action->elementStart('ul', array('class' => 'nav'));
|
||||
|
Loading…
Reference in New Issue
Block a user