After logging in from /user or /user/login, the page redirects to /user, which is results in "Access denied". Instead, when logging in from /user or /user/login you should be redirected to /user/"uid". Also, /user should redirect to /user/"uid" when logged in.
Marked as critical since users shouldn't see "Access denied" when logging in.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | patch_40.txt | 1.12 KB | webernet |
| #24 | patch_39.txt | 2.06 KB | webernet |
| #21 | patch_38.txt | 2.2 KB | webernet |
| #19 | user_menu_trickery_0.patch | 2.05 KB | chx |
| #14 | user_menu_trickery.patch | 2 KB | chx |
Comments
Comment #1
ChrisKennedy commentedLooks like "user/login shouldn't be accessible for logged in users" might have caused this problem. In particular, this segment:
It doesn't appear that the uid can be included in that action since the user hasn't logged in yet.
Comment #2
ChrisKennedy commentedSorry, "user/login shouldn't be accessible for logged in users" -> http://drupal.org/node/69985
Comment #3
chx commentedThis is the simple fix for it. Note that the code alreasy present in the beginning of
user_loginto deal with the case when called after login. Cases tested: logging in from block when viewing a node (landed on the node), logging in from 'user' (landed on user/1), trying to access user/login when logged in (landed on user/1 again).Comment #4
moshe weitzman commentedthe whole point of making user/login inaccessible is that you could add that path to a menu and it would only show up for anon users. this patch reverted that. perhaps a better fix is to point the login form at some path other than user/login.
Comment #5
webernet commentedCommitted by Dries: http://drupal.org/node/88474
I can confirm that it fixes the "Access denied" issue.
Comment #6
chx commentedSo, you guys want a user/login which is accessible for anons only so you can add it to the menu?
Comment #7
chx commentedThe access attribute for the menu item of 'user' is never consulted because there is a default task. On the other hand, the callback attribute of user/login is totally unnecessary, because it will happily fall back to the one given at user and if you do not give one for user then you won't get a user login callback at 'user' when anonymous. So, if you want, you can use this patch as well. It will drive people nuts, but noone understands menu system anyways, so it does not matter.
Comment #8
chx commentedI wasked about my last sentence: people here are the poor developers who need to understand user_menu and need to compile a [callback, callback arguments, access] package from two definitons... or this is my current understanding. Let' see whether the second patch works or not...
Comment #9
webernet commentedEither patch appears to work correctly.
Another review, and it should be RTBC.
Comment #10
webernet commentedPatch in #6 is RTBC.
#7 works, but may make another bug more obvious (http://drupal.org/node/72674) - when a link to /user/login is in primary links, /user becomes inaccessible to anonymous users (/user/login is OK).
Comment #11
dries commentedDoing a redirect while building the menu? This looks like an ugly solution to me. Can't we chose not to add the menu item when $user->uid is set? I'm trying to understand why we add the menu item to begin with.
Comment #12
chx commentedI have been asked that the path user should provide the login form when anonymous and the view of current logged in user otherwise. I have been asked to make it so that if someone adds user/login to his menu then it disappear when logged in. If there is any other way to satisfy all these requirements, it escapes me.
Note that I redirect during hook_menu !$may_cache because this is the earliest stage when such a redirect is feasible.
Also note that the big menu rewrite will clean up this "default task links to parent" nightmare but at this stage attemtping to change the behaviour of the menu system is not the best solution.
Comment #13
moshe weitzman commented@dries - the reason we need a 'user/' menu item is that we want to write links to 'view your user profile' from within a node or comment but not require php permissions to do so. in other words, a link which does not require knowing the current uid. already, it is impossible write a link to 'edit you user profile' without php access and thats a support problem on my sites and on drupal.org
Comment #14
chx commentedThis patch works, you can have a login link in your menu if you point that to user (user/login does not work because of http://drupal.org/node/72674 ) . This patch depends on http://drupal.org/node/88707 .
Comment #15
chx commentedNote that this also does a redirect while building the menu just an 'inner' redirect. I still can't find any solution not employing redirection.
Comment #16
Richard Archer commentedchx asked me to have a look at this issue.
I agree with chx and Moshe that this is a problem that should be addressed.
I also agree with Dries that this solution looks a little ugly.
But I can't immediately see a better way.
Comment #17
chx commentedSo, we either commit #6 or commit http://drupal.org/node/88707 (which is needed anyways) plus #14.
Comment #18
drummI tried #14-
patching file modules/user/user.module
Hunk #1 FAILED at 690.
1 out of 2 hunks FAILED -- saving rejects to file modules/user/user.module.rej
I think the way to test this is to log in and go to '/user' and '/user/login' and see if there is any problem, but I couldn't find any with unpatched code.
Comment #19
chx commentedRerolled, added comments.
Comment #20
dries commentedWhat do you mean with 'without writing PHP code'? I think the code comment is quite fuzzy.
Comment #21
webernet commentedUpdated the comment to be more clear.
Comment #22
chx commentedPer Drumm's request, this patch serves lets you create two menu items (primary links):
If you say this is a feature request, I do not agree. This was possible but was broken by the bugfix committed earlier.
Comment #23
dries commentedCommitted to CVS HEAD. Thanks.
Comment #24
webernet commentedWhoops - looks like a couple lines of code weren't properly removed (two copies of user/login).
Patch removes them and does a little formatting cleanup of some nearby lines.
Comment #25
webernet commentedSame patch, minus the formatting fixes.
Comment #26
chx commentedYup. (how come these lines were not removed? ? ? anyways, this ends our long and ugly journey, I hope)
Comment #27
dries commentedCommitted to CVS HEAD. Thanks.
Comment #28
(not verified) commented