diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-07-07 08:05:01 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-07-07 08:05:01 +0000 |
commit | ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2 (patch) | |
tree | 5561cfced677d44bff71b9b2955139cec9387226 /modules/user | |
parent | a8812bb727a08296a2029fcb055767bc4b783fb0 (diff) | |
download | brdo-ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2.tar.gz brdo-ea4f6bcef2f1c3ba8f84115d3de3af0d8e5820d2.tar.bz2 |
#363580 by rfay, chx, Berdir, Rob Loach, Gábor Hojtsy, Shawn DeArmond: Fixed OpenID login fails when in maintenance mode, and 403 errors on certain user paths for logged-in users.
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/user.module | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index 0fa22cb09..226f2f152 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1741,6 +1741,48 @@ function user_menu() { } /** + * Implements hook_menu_site_status_alter(). + */ +function user_menu_site_status_alter(&$menu_site_status, $path) { + if ($menu_site_status == MENU_SITE_OFFLINE) { + // If the site is offline, log out unprivileged users. + if (user_is_logged_in() && !user_access('access site in maintenance mode')) { + module_load_include('pages.inc', 'user', 'user'); + user_logout(); + } + + if (user_is_anonymous()) { + switch ($path) { + case 'user': + // Forward anonymous user to login page. + drupal_goto('user/login'); + case 'user/login': + case 'user/password': + // Disable offline mode. + $menu_site_status = MENU_SITE_ONLINE; + break; + default: + if (strpos($path, 'user/reset/') === 0) { + // Disable offline mode. + $menu_site_status = MENU_SITE_ONLINE; + } + break; + } + } + } + if (user_is_logged_in()) { + if ($path == 'user/login') { + // If user is logged in, redirect to 'user' instead of giving 403. + drupal_goto('user'); + } + if ($path == 'user/register') { + // Authenticated user should be redirected to user edit page. + drupal_goto('user/' . $GLOBALS['user']->uid . '/edit'); + } + } +} + +/** * Implements hook_init(). */ function user_init() { |