summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-08-16 19:50:37 -0400
committerCraig Andrews <candrews@integralblue.com>2009-08-16 19:50:37 -0400
commit136a69a387719d560f97b6f8ee73d1224b2bac8c (patch)
treee9c0c02d89119a9d8c35b2d0c2485d8d888a65f4
parent46c77b83b1b10663ac80f6e1df604d529bb31dd4 (diff)
parent75a0a3e18b001454ab4844bc63d4052faf502138 (diff)
Merge commit 'jeff-themovie/0.8.x-openid-enabled' into 0.8.x
-rw-r--r--README8
-rw-r--r--actions/finishopenidlogin.php4
-rw-r--r--actions/login.php6
-rw-r--r--actions/openidlogin.php4
-rw-r--r--actions/openidsettings.php6
-rw-r--r--actions/register.php24
-rw-r--r--config.php.sample3
-rw-r--r--lib/accountsettingsaction.php4
-rw-r--r--lib/common.php8
-rw-r--r--lib/logingroupnav.php6
10 files changed, 60 insertions, 13 deletions
diff --git a/README b/README
index e37934aaa..023061b80 100644
--- a/README
+++ b/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
---
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);
diff --git a/config.php.sample b/config.php.sample
index 8b4b777f2..1dc123aaf 100644
--- a/config.php.sample
+++ b/config.php.sample
@@ -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;
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php
index 4ab50abce..1a21d871e 100644
--- a/lib/accountsettingsaction.php
+++ b/lib/accountsettingsaction.php
@@ -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],
diff --git a/lib/common.php b/lib/common.php
index f26155e70..3fc047af9 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -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';
diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php
index 919fd3db9..2fb1828d6 100644
--- a/lib/logingroupnav.php
+++ b/lib/logingroupnav.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'));