//override if needed
}
+ /**
+ * Hook for overriding behaviour before going to the login page.
+ *
+ * This method is called from require_login from potentially any page for
+ * all enabled auth plugins and gives each plugin a chance to redirect
+ * directly to an external login page, or to instantly login a user where
+ * possible.
+ *
+ * If an auth plugin implements this hook, it must not rely on ONLY this
+ * hook in order to work, as there are many ways a user can browse directly
+ * to the standard login page. As a general rule in this case you should
+ * also implement the loginpage_hook as well.
+ *
+ */
+ function pre_loginpage_hook() {
+ // override if needed, eg by redirecting to an external login page
+ // or logging in a user:
+ // complete_user_login($user);
+ }
+
/**
* Post authentication hook.
* This method is called from authenticate_user_login() for all enabled auth plugins.
if (!empty($_SERVER['HTTP_REFERER'])) {
$SESSION->fromurl = $_SERVER['HTTP_REFERER'];
}
- redirect(get_login_url());
- exit; // Never reached.
+
+ // Give auth plugins an opportunity to authenticate or redirect to an external login page
+ $authsequence = get_enabled_auth_plugins(true); // auths, in sequence
+ foreach($authsequence as $authname) {
+ $authplugin = get_auth_plugin($authname);
+ $authplugin->pre_loginpage_hook();
+ if (isloggedin()) {
+ break;
+ }
+ }
+
+ // If we're still not logged in then go to the login page
+ if (!isloggedin()) {
+ redirect(get_login_url());
+ exit; // Never reached.
+ }
}
}