Using the theme garland, as an anonymous user who does not have the permission to view user profiles, go to:

http://drupal/user/1
and you get Access denied as expected.

Now go to:
http://drupal/user/reset/1/1237373980/ed4f7d7b5a345d1somerandomstuffanyt...
and you get access denied but the page (theme) is printed twice.

Comments

beginner’s picture

user_menu():

  $items['user/reset/%/%/%'] = array(
    'title' => 'Reset password',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_pass_reset', 2, 3, 4),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'user.pages.inc',
  );

user_pass_reset:

    else {
      // Deny access, no more clues.
      // Everything will be in the watchdog's URL for the administrator to check.
      drupal_access_denied();
    }

This may be due to the combination of drupal_get_form() and drupal_access_denied(). ??

beginner’s picture

Version: 6.x-dev » 7.x-dev
sun’s picture

Status: Active » Needs review
StatusFileSize
new749 bytes

That's because drupal_access_denied() does not end the request.

dries’s picture

It would be better to re-factor the code so we don't have to call exit(). Calling exit() is quite drastic and prevents that certain handlers run, e.g. register_shutdown_function() handlers.

pp’s picture

I couldn't reproduce this bug.

I got the fresh copy from cvs.
Installed the Drupal.
Logged out.
Viewed the url.
I didn't see the theme printed twice.

What should I do?

pp

catch’s picture

Status: Needs review » Postponed (maintainer needs more info)

You should mark it as needs more info ;)

sun’s picture

Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Needs work

I think it is unimportant whether this can be replicated or not.

This issue clearly identifies that the proper usage of drupal_access_denied() - which is important for security - is unknown.

Proposal:

- Let drupal_access_denied() return MENU_ACCESS_DENIED and not print anything at all.

- Rename drupal_access_denied() to drupal_access_denied_page(), so it clearly describes that it outputs a page.

- So developers can simply do:

return drupal_access_denied();

- And index.php will ensure to take the appropriate steps.

Given the regular page request and processing flow, I think that would be much more grokable. At least, every other callback in Drupal returns something. For any reason, we apply a completely different concept here.

FWIW, the same applies to drupal_not_found().

If there is an important reason to handle these pages so differently, then we should at least update the PHPDocs of those functions to contain a code example that clearly shows how developers should implement the function. That said, this issue makes me nervous whether I'm using those functions properly in my modules.

sun’s picture

moshe weitzman’s picture

Priority: Critical » Normal

sun's ideas are good but not critical, imo

Tor Arne Thune’s picture

Status: Needs work » Closed (fixed)

Not an issue in Drupal 7.0. Can't replicate the bug.

sun’s picture

Title: user/reset: theme printed twice when access denied » Theme printed twice when access denied
Version: 7.x-dev » 8.x-dev
Component: user system » base system
Category: bug » task
Priority: Normal » Major
Status: Closed (fixed) » Active

We should investigate the proposed improvements for D8.

Technician’s picture

Received same problem after update D7.12 -> D7.14. Do not remember anything like this before update.

Technician’s picture

Downgrade back to D7.12 not help - problem persists.

dgastudio’s picture

Priority: Major » Critical

same problem, my users can't login after register new account (new accounts are validated by email)

dgastudio’s picture

applying the patch from #3, solves the problem with duplicated theme content. by users still can't access to password reset/set form.

sun’s picture

Version: 8.x-dev » 7.x-dev
Priority: Critical » Normal
Status: Active » Closed (won't fix)

#1463656: Add a Drupal kernel; leverage HttpFoundation and HttpKernel makes this entire issue obsolete for D8.

In D7, this should not happen, but if it does, then that hints at some broken code in a module or theme.

In D6 and below, this can happen more often, but there's no way to fix that other than refactoring access/page callback code (core code should not be affected though).

fusionteam’s picture

Version: 7.x-dev » 7.15
Status: Closed (won't fix) » Active
StatusFileSize
new4.66 KB

In my case that issue appears when I call drupal_access_denied() in one of my hooks. The page is displayed twice, stacked vertically.

Then I tried to do the following:

drupal_access_denied();
exit;

After that the page displayed only once, but I the output is a bit strange. See the attached image.

pasqualle’s picture

Version: 7.15 » 7.x-dev
Issue summary: View changes
Status: Active » Closed (fixed)

as sun wrote, when you see this problem then you have broken code in a module or theme.

pasqualle’s picture

Status: Closed (fixed) » Closed (won't fix)