Problem/Motivation

Currently users have routes such as /user which automatically redirects to the currently logged in users page.

In some cases this makes it very cumbersome to add a link to a users editing page without adding custom code. It would be very convenient to simply add in a link to 'user/edit' in, say, a simple HTML block.

Proposed resolution

Add another convenience route /user/edit which automatically redirects to the currently logged in users page.

The user controller already has this functionality to direct to the active users edit page. This only requires the addition of the route.

Remaining tasks

  • Add the route 'user/edit'.
  • Add some relevant tests to the user controller.
  • Get feed back from the community.
  • Commit that bad boy.

API changes

No backwards compatibility issues. This simply adds a new route so it should be placed into a minor release.

Comments

DerekCresswell created an issue. See original summary.

derekcresswell’s picture

Status: Active » Needs review
StatusFileSize
new3.01 KB

Changes in this patch :

  • Addition of the user.edit route.
  • A change in the comment for the UserController::userEditPage() function to generalise it because of it's new use.
  • An addition of a UserControllerTest class which contains a test for this method. Note, this class is not complete and could later be expanded to include other functions from the class.
derekcresswell’s picture

I will also note, I am aware of the module user_current_paths. This does accomplish what I am after but I believe that this functionality should be moved into core. It is simple to implement and an easy to find use case.

Worth while to put into core.

ayushmishra206’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new13.06 KB

Patch applies cleanly on the latest branch and redirects the user successfully to the users page.

derekcresswell’s picture

Issue summary: View changes
derekcresswell’s picture

StatusFileSize
new3.1 KB

Changed the assertion in the test to use an exact match to an absolute URL.

jonathanshaw’s picture

+++ b/core/modules/user/user.routing.yml
@@ -128,6 +128,13 @@ user.page:
+  defaults:
+    _controller: '\Drupal\user\Controller\UserController::userEditPage'

This needs a title

Otherwise good I think.

derekcresswell’s picture

StatusFileSize
new3.13 KB

Added the title 'Edit account'.

catch’s picture

Status: Reviewed & tested by the community » Needs review

This directly conflicts with #2360971: The user.page route only redirects, so remove it which is trying to remove the /user route. Generally I think we should make it easier to add a direct link here.

derekcresswell’s picture

That issue has not been active for 5 years.

If you ask me, the method here looks much more straight forward and simple than what is linked. But I could see the benefit in the method listed there.

I will take a look a deeper look at that and see if it can be fixed up and or closed. Either way, I feel we need to have both /user and /user/edit links available (no matter how they are implemented). These are essential to quickly and easily create a site.

abhijith s’s picture

Applied patch #8 and it works fine.The /user/edit will be redirected to current logged-in user's account page after applying this patch.

RTBC

tanubansal’s picture

Tested #8 on 9.1, RTBC + 1

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new872.39 KB

I have reviewed the #8 patch on drupal 9.2 dev version,the patch works fine.
After patchafter patch.
RTBC

derekcresswell’s picture

Status: Needs review » Reviewed & tested by the community

Changing status based on new comments. #9 needs to be addressed still, but I feel the method outlined here is the way to go.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 3168624-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new3.13 KB
new1.06 KB

Fixed some CS issues of patch #8.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

b_sharpe’s picture

Status: Needs review » Reviewed & tested by the community

Applies, has tests and works as intended. RTBC

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bramdriesen’s picture

RTBC +1

jonathanshaw’s picture

I think this feature request is valid, and easier to fix than #2360971: The user.page route only redirects, so remove it.

It will be easy to later adjust the solution developed here as part of #2360971: The user.page route only redirects, so remove it. so I'm not sure that this needs to be blocked on that.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

Discussed with @catch. We agreed that this does not make #2360971: The user.page route only redirects, so remove it harder and the intention to make it easier to link to user edit pages is useful. In order to land this change we need a change record to tell people about it. See the "add change notice" link above.

bramdriesen’s picture

Assigned: Unassigned » bramdriesen

I will make an attempt at drafting a CR.

bramdriesen’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

Here is the change record. Not sure if it needs more info (looking at more recent CR's content seems to be limited).

https://www.drupal.org/node/3313603

It's unpublished so the core committer can set the tagged version and publish it after it's done.

bramdriesen’s picture

Assigned: bramdriesen » Unassigned
jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

I tweaked the CR a bit.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Backported to 9.5.x as a low risk feature request - don't see why we need to wait till 10.1.x for this.

Committed and pushed b61cd96e9d to 10.1.x and fa7196afd4 to 10.0.x and e123dd96cf to 9.5.x. Thanks!

  • alexpott committed b61cd96 on 10.1.x
    Issue #3168624 by DerekCresswell, ravi.shankar, BramDriesen,...

  • alexpott committed fa7196a on 10.0.x
    Issue #3168624 by DerekCresswell, ravi.shankar, BramDriesen,...

  • alexpott committed e123dd9 on 9.5.x
    Issue #3168624 by DerekCresswell, ravi.shankar, BramDriesen,...

Status: Fixed » Closed (fixed)

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