Commit abffaebe authored by Evan Prodromou's avatar Evan Prodromou

event for determining if an action is a login action

parent c378cc97
...@@ -142,3 +142,6 @@ SensitiveAction: determines if an action is 'sensitive' and should use SSL ...@@ -142,3 +142,6 @@ SensitiveAction: determines if an action is 'sensitive' and should use SSL
- $action: name of the action, like 'login' - $action: name of the action, like 'login'
- $sensitive: flag for whether this is a sensitive action - $sensitive: flag for whether this is a sensitive action
LoginAction: determines if an action is a 'login' action (OK for public view in private mode)
- $action: name of the action, like 'register'
- $login: flag for whether this is a login action
...@@ -105,6 +105,20 @@ function checkMirror($action_obj) ...@@ -105,6 +105,20 @@ function checkMirror($action_obj)
} }
} }
function isLoginAction($action)
{
static $loginActions = array('login', 'openidlogin', 'finishopenidlogin',
'recoverpassword', 'api', 'doc', 'register');
$login = null;
if (Event::handle('LoginAction', array($action, &$login))) {
$login = in_array($action, $loginActions);
}
return $login;
}
function main() function main()
{ {
// quick check for fancy URL auto-detection support in installer. // quick check for fancy URL auto-detection support in installer.
...@@ -164,8 +178,7 @@ function main() ...@@ -164,8 +178,7 @@ function main()
// parts of the site, redirect to login // parts of the site, redirect to login
if (!$user && common_config('site', 'private') && if (!$user && common_config('site', 'private') &&
!in_array($action, array('login', 'openidlogin', 'finishopenidlogin', !isLoginAction($action) &&
'recoverpassword', 'api', 'doc', 'register')) &&
!preg_match('/rss$/', $action)) { !preg_match('/rss$/', $action)) {
common_redirect(common_local_url('login')); common_redirect(common_local_url('login'));
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment