diff options
author | Jeffery To <jeffery.to@gmail.com> | 2009-08-09 19:12:59 +0800 |
---|---|---|
committer | Jeffery To <jeffery.to@gmail.com> | 2009-08-10 13:57:39 +0800 |
commit | 14b46e2183f10359cc53d597913a878f53e23719 (patch) | |
tree | 5abe41f6f475be0a05168f8859542e1a1a3b3b21 /index.php | |
parent | c1b19929f6234c4b9e30e16bae419c89c38c1169 (diff) |
Added configuration option to only allow OpenID logins.
If $config['site']['openidonly'] is set to true:
* the Login/Register pages will be removed from the navigation;
* directly accesses to the Login/Register pages will redirect to the
OpenID login page;
* most links to the Login/Register pages will link to the OpenID login
page instead.
The user will still need to set a password to access the API and RSS
feeds.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -182,12 +182,20 @@ function main() // If the site is private, and they're not on one of the "public" // parts of the site, redirect to login - if (!$user && common_config('site', 'private') && - !in_array($action, array('login', 'openidlogin', 'finishopenidlogin', - 'recoverpassword', 'api', 'doc', 'register')) && - !preg_match('/rss$/', $action)) { - common_redirect(common_local_url('login')); - return; + if (!$user && common_config('site', 'private')) { + $public_actions = array('openidlogin', 'finishopenidlogin', + 'recoverpassword', 'api', 'doc'); + $login_action = 'openidlogin'; + if (!common_config('site', 'openidonly')) { + $public_actions[] = 'login'; + $public_actions[] = 'register'; + $login_action = 'login'; + } + if (!in_array($action, $public_actions) && + !preg_match('/rss$/', $action)) { + common_redirect(common_local_url($login_action)); + return; + } } $action_class = ucfirst($action).'Action'; |