From 58fe1a597c76dd6737abbe44e7cb7111d3ae3375 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 28 May 2010 16:52:17 -0700 Subject: [PATCH] OpenID: add option to enable asking for a username to append to the trusted provider's base URL. Good for hooking up with sites like WikiHow, where usernames are appended to a base URL to get a profile URL which is used as the provider. $config['openid']['append_username'] = true; or check 'Append a username to base URL' in OpenID admin panel. --- plugins/OpenID/openid.php | 2 ++ plugins/OpenID/openidadminpanel.php | 10 ++++++++++ plugins/OpenID/openidlogin.php | 20 +++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php index 574ecca72b..8be02e031c 100644 --- a/plugins/OpenID/openid.php +++ b/plugins/OpenID/openid.php @@ -144,8 +144,10 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) // Handle failure status return values. if (!$auth_request) { + common_log(LOG_ERR, __METHOD__ . ": mystery fail contacting $openid_url"); return _m('Not a valid OpenID.'); } else if (Auth_OpenID::isFailure($auth_request)) { + common_log(LOG_ERR, __METHOD__ . ": OpenID fail to $openid_url: $auth_request->message"); return sprintf(_m('OpenID failure: %s'), $auth_request->message); } diff --git a/plugins/OpenID/openidadminpanel.php b/plugins/OpenID/openidadminpanel.php index 0633063662..ce4806cc89 100644 --- a/plugins/OpenID/openidadminpanel.php +++ b/plugins/OpenID/openidadminpanel.php @@ -91,6 +91,7 @@ class OpenidadminpanelAction extends AdminPanelAction ); static $booleans = array( + 'openid' => array('append_username'), 'site' => array('openidonly') ); @@ -222,6 +223,15 @@ class OpenIDAdminPanelForm extends AdminForm ); $this->unli(); + $this->li(); + $this->out->checkbox( + 'append_username', _m('Append a username to base URL'), + (bool) $this->value('append_username', 'openid'), + _m('Login form will show the base URL and prompt for a username to add at the end. Use when OpenID provider URL should be the profile page for individual users.'), + 'true' + ); + $this->unli(); + $this->li(); $this->input( 'required_team', diff --git a/plugins/OpenID/openidlogin.php b/plugins/OpenID/openidlogin.php index 8c559c9346..ffedc64810 100644 --- a/plugins/OpenID/openidlogin.php +++ b/plugins/OpenID/openidlogin.php @@ -32,6 +32,9 @@ class OpenidloginAction extends Action $provider = common_config('openid', 'trusted_provider'); if ($provider) { $openid_url = $provider; + if (common_config('openid', 'append_username')) { + $openid_url .= $this->trimmed('openid_username'); + } } else { $openid_url = $this->trimmed('openid_url'); } @@ -94,7 +97,15 @@ class OpenidloginAction extends Action function showScripts() { parent::showScripts(); - $this->autofocus('openid_url'); + if (common_config('openid', 'trusted_provider')) { + if (common_config('openid', 'append_username')) { + $this->autofocus('openid_username'); + } else { + $this->autofocus('rememberme'); + } + } else { + $this->autofocus('openid_url'); + } } function title() @@ -122,10 +133,17 @@ class OpenidloginAction extends Action $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $provider = common_config('openid', 'trusted_provider'); + $appendUsername = common_config('openid', 'append_username'); if ($provider) { $this->element('label', array(), _m('OpenID provider')); $this->element('span', array(), $provider); + if ($appendUsername) { + $this->element('input', array('id' => 'openid_username', + 'name' => 'openid_username', + 'style' => 'float: none')); + } $this->element('p', 'form_guide', + ($appendUsername ? _m('Enter your username.') . ' ' : '') . _m('You will be sent to the provider\'s site for authentication.')); $this->hidden('openid_url', $provider); } else { -- 2.39.2