Problem/Motivation

When redirecting to the current page with tag as described in the redirect destination field is not working. When destination is saved for the page gets redirected to the /user page.

Steps to reproduce

  1. Add login-destination rule (/admin/config/people/login-destination/add)
  2. set tag in the Redirect destination field
  3. Save rule
  4. Logout
  5. Go to specific page
  6. Login
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Vincent_Minsky created an issue. See original summary.

rkoller’s picture

I've noticed the same when testing the module today for the first time. I've set up the triggers to Login and Logout and the Redirect destination to <current>. Pages is set to All pages, language to All languages and roles to all available roles (Authenticated and Administrator).
If I am on /node/2 now and log out i get redirected to /node . Same the other way around if i am on /node/2 and try to log in i get redirected also to /node. I would expect that the redirection would point to /node/2 again

Tested on Drupal 9.2.6 running on DDEV with PHP 7.4.23 andnginx/1.20.1

gaurav.kapoor’s picture

I think for this scenario it is better to use destination query. You can write a simple JS which will set destination query parameter in login and logout link to current page and thus use core provided behavior for redirection.

sriharsha.uppuluri’s picture

StatusFileSize
new600 bytes

I'm also facing the similar issue created the patch by using the getPathInfo.

satya.eedeti made their first commit to this issue’s fork.

satya.eedeti’s picture

The patch #4 works very well but somehow it is failing with domains with base path. For example, we have two sites example.com (base site) and example.com/IN-en (country site). If we login from country site, then it is getting redirected to base site, as getPathInfo omits the base path. The patch attached here is working fine for both sites/scenarios.

jon.lund’s picture

My installation was working fine until Core 9.4.5 update. Now this module seems broken. My users are very used to being redirected to the current page upon login. I have been using this module for about 8 years. I am hopeful a fix is forthcoming.

andrenoronha’s picture

Not working for me either. I'm using Drupal 9.5.2 and o365 to authenticate users.
It seems to recognize /login as the current page.

heliogabal’s picture

I tested the patch and the redirect to <current> is working again after applying the patch (#6) on Drupal 9.4.12.

grahamshepherd’s picture

Patch #6 does not work for me.
Drupal 9.5.8
Login_destination 8.x-2.0-beta6
Redirect set to for login redirects to user page and logout to the home page.

If I try and use token: /[current-page:url:path] the website reports an error.

grahamshepherd’s picture

Patch #4 doesn't work either.

proweb.ua’s picture

#6 does not work

nikhil_110’s picture

StatusFileSize
new12.49 MB
new634 bytes

Attached patch against Comment #10, #11, #12

  1. Setup Drupal with Login Destination V8.x-2.0-beta1
  2. Enabled Login Destination module
  3. Go to Administration > Configuration > People > Login destinations > Add Login Destination
  4. And set Redirect upon triggers is Logout and Redirect destination Path is
  5. Apply this patch.
  6. Clear cache.

Gaurav Gupta made their first commit to this issue’s fork.

gaurav gupta’s picture

Status: Active » Needs review
rakesh.regar’s picture

Status: Needs review » Needs work

I have tested these changes and it works fine.

But this change disable cache for user account block, for people using page as destination we can use this but for people who are not using as detination, it is not recommanded.

Disabling cache will reduce performance, better solution would be having some kind of check using which it can be determind if a user have set redirection to the current page only then we should stop caching this block.

manish-31 made their first commit to this issue’s fork.

manish-31’s picture

Status: Needs work » Needs review

I have updated the ! MR 17, needs review.

Instead of disabling caching for the account block added cache contexts for url.path.

We don't need any check to confirm if destination rules have <current> path redirection or not as caching will happen based on the path.

sourabhsisodia_’s picture

StatusFileSize
new4.51 MB

Tested the MR!, user after logging in is redirected to the current path. The MR is also working for other paths. RTBC++

sourabhsisodia_’s picture

Status: Needs review » Reviewed & tested by the community

rsvelko made their first commit to this issue’s fork.

rsvelko’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all for the report and MR.
I've just merged and it's now into the dev branch.
My next step is to look for other RTBC-s, test them and group them into new release 8.x-2.0-beta7.

manish-31’s picture

Hi @rsvelko,
Thanks for merging the MR.

I noticed that I wasn't credited for resolving this issue. I'm not sure why that happened. Is there something I'm missing?

Status: Fixed » Closed (fixed)

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

rsvelko’s picture

Giving credit. Thanks everyone.

shadab majid’s picture

I have applied this patch but its not working.