Problem/Motivation

When a logged-in user requests a new password on '/user/password', the page shows an additional tab 'Log in'. This tab should not be available on this page, as the user is already logged in. This behavior is specific for Drupal 8 and is therefor a regression.

For logged-out users, the tab 'Log in' is missing as well.

Proposed resolution

@dinarcon #5 / #6
The extra tab is defined by the user.page plugin at user.links.task.yml. It has a base_route of user.page. The latter has a requirement of _user_is_logged_in: 'TRUE', at user.routing.yml, making the task available for logged in users. Having a 'Log in' link only available for logged in users is odd.

To mimic D7's behaviour, in user.links.task.yml the user.page plugin definition should be removed and and the user.login plugin definition should be changed to:

user.login:
 route_name: user.login
 base_route: user.page
 title: 'Log in'
 weight: -10

Remaining tasks

  • Write a patch
  • Review
  • Add screenshots of the user/password page after patch

The tab 'Log in' should only be available for logged-out users.

User interface changes

The 'Request new password' page shows no tabs by default

API changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because the display is a regression compared to D7
Issue priority Normal because the functionality is not impacted
Unfrozen changes Unfrozen because it only changes the display of tabs
Prioritized changes The main goal of this issue is usability.

Original report by @gaurav_varshney

The issue contanins when a user is logged in and go for "Request New Password" then the page display the "Log In" Link which i think should not for the logged in user.

Proposed Resolution -
we can remove the both tabs (Log in and Request new password).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gaurav_varshney’s picture

Assigned: gaurav_varshney » Unassigned
idebr’s picture

Title: Remove Log In and Request New Password Tab for Logged In User » Tab 'Log in' shows on 'Request new password page for Logged In User
Issue tags: +Regression
FileSize
96.4 KB

I believe the tabs will not be shown by default if there is only one tab available. This is also the behavior currently in D7:

idebr’s picture

Component: user system » user.module
AkshayKalose’s picture

Assigned: Unassigned » AkshayKalose
dinarcon’s picture

IMHO, none of tabs should be shown as proposed by @gaurav_varshney. That is the behaviour in D7 as @idebr shows and, as stated, having a single link task available will hide the tabs.

The extra tab is defined by the user.page plugin at user.links.task.yml. It has a base_route of user.page. The latter has a requirement of _user_is_logged_in: 'TRUE', at user.routing.yml, making the task available for logged in users. Having a 'Log in' link only available for logged in users is odd. In D7, there is a 'Log in' link for this page for anonymous users as seen below. This is not true for D8, but trying to achieve that might have introduced this issue.

Anonymous user password reset screen in Drupal 7

dinarcon’s picture

Issue tags: +Novice

To mimic D7's behaviour, in user.links.task.yml the user.page plugin definition should be removed and and the user.login plugin definition should be changed to:

user.login:
  route_name: user.login
  base_route: user.page
  title: 'Log in'
  weight: -10

Waiting for feedback. Tagging as Novice.

idebr’s picture

Title: Tab 'Log in' shows on 'Request new password page for Logged In User » Tab 'Log in' shows on 'Request new password page for logged-in users
Issue summary: View changes
Issue tags: +Needs tests

Updated the issue summary with the default template to clear the path forward.

AkshayKalose’s picture

Suggestion from #6
Log In Tab Updates

kporras07’s picture

Status: Active » Needs review
FileSize
416 bytes

I think proposed solution in #8 will give us a bad name for the user and password login tab if another authentication method add pages below user/login/

For avoiding this issue and as a proposed solution for this issue I'd only change route_name in user.page in user.links.task.yml to user.login.

Patch attached with this proposed solution. (Screenshots are exactly the same as #8)

Status: Needs review » Needs work

The last submitted patch, 9: log-in-tab-visibility-2303391-9.patch, failed testing.

AkshayKalose’s picture

Assigned: AkshayKalose » Unassigned

The above patch seems to be working for me.

Status: Needs work » Needs review

The last submitted patch, 8: log-in-tab-visibility-2303391-8.patch, failed testing.

kporras07’s picture

@AkshayKalose; problem here is about integration tests. As I didn't modified the test; it fails on it. I'll try to correct this ASAP.

Status: Needs review » Needs work

The last submitted patch, 9: log-in-tab-visibility-2303391-9.patch, failed testing.

vaibhavjain’s picture

Status: Needs work » Needs review
Issue tags: +#dcdelhi
FileSize
793 bytes

Patch attached, looks to be working good.

Status: Needs review » Needs work

The last submitted patch, 16: 2303391-16-rectifying-tabs.patch, failed testing.

vaibhavjain’s picture

I believe the patch is fine, but it also needs to update the test case.
May be removing user.page with user.login in the file -> UserLocalTasksTest.php -> testUserLoginLocalTasks()

gvso’s picture

Status: Needs work » Needs review
FileSize
1.59 KB

Test updated

gvso’s picture

Removing extra spaces :)

The last submitted patch, 19: log-in-tab-visibility-2303391-19.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 20: log-in-tab-visibility-2303391-20.patch, failed testing.

gvso’s picture

Status: Needs work » Needs review
FileSize
2.01 KB
idebr’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests
FileSize
83.9 KB
103.31 KB

Looks great, thanks everyone!

Screenshot after (logged out):

Screenshot after (logged in):

idebr’s picture

Title: Tab 'Log in' shows on 'Request new password page for logged-in users » Tab 'Log in' shows on 'Request new password page for logged-in users and is missing for logged-out users
Issue summary: View changes

Updated the issue summary to include the change to the tab 'Log in'.

idebr’s picture

Issue summary: View changes

Included a beta evaluation in the issue summary.

gvso’s picture

Thanks @idebr, but as our dataProvider is not returning a second parameter anymore, should we remove the second parameter in the testUserLoginLocalTasks() method and the if statement too?

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

@gvso - yep good spot. We can remove the subtask handling from testUserLoginLocalTasks

gvso’s picture

Thanks @alexpott. Test updated

gvso’s picture

Status: Needs work » Needs review
idebr’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
742 bytes

Alright then! I added an interdiff for easier reviewing.

gvso’s picture

Thanks @idebr, I forgot to do that :)

msound’s picture

Patch #29 works. I tested this manually, and ran phpunit for `user` group. RTBC++

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +SprintWeekend2015

Nice find and fix. Looks like Alex's feedback was addressed.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 5726f6e on 8.0.x
    Issue #2303391 by gvso, idebr, AkshayKalose, gaurav_varshney, dinarcon,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.