From 7dc3a90d1252137859a687e32313ea569dcf8796 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Thu, 13 Aug 2009 22:18:06 +0800 Subject: 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. --- actions/finishopenidlogin.php | 4 +++- actions/login.php | 6 +++++- actions/openidlogin.php | 4 +++- actions/openidsettings.php | 6 ++++++ actions/register.php | 24 ++++++++++++++++-------- 5 files changed, 33 insertions(+), 11 deletions(-) (limited to 'actions') diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php index ba1e933e3..a29195826 100644 --- a/actions/finishopenidlogin.php +++ b/actions/finishopenidlogin.php @@ -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'); diff --git a/actions/login.php b/actions/login.php index c20854f15..6f1b4777e 100644 --- a/actions/login.php +++ b/actions/login.php @@ -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.'); } } diff --git a/actions/openidlogin.php b/actions/openidlogin.php index a8d052096..744aae713 100644 --- a/actions/openidlogin.php +++ b/actions/openidlogin.php @@ -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'); diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 5f59ebc01..40a480dc4 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -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', diff --git a/actions/register.php b/actions/register.php index 046a76b80..683d21af8 100644 --- a/actions/register.php +++ b/actions/register.php @@ -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); -- cgit v1.2.3-54-g00ecf