Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 342 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drupal Rules + one-time-login redirect issue

#1
Problem is as follows:

I have a rule which redirects users to a landing page after login. It works fine.

However, if a user forgets their password, they are sent a link to the one-time-login page. They click the button and (because of my rule) are sent to their landing page.

The problem of course is that they cannot then change their password because the normal password change (in the user profile) requires you know your password to change it.

So how would I modify my redirect rule to say:

"Redirect to landing page, unless the logging-in user is coming from the one-time-login screen" or "Redirect to the landing page, unless the target URL starts with /user/reset/* (can you wildcard??)"

Thanks in advance for any tips
Reply

#2
There is a Path Rules module and Rules Bonus Pack module that could do this nicely in Drupal 6. But unfortunately it looks like this feature/module is not coming for Drupal 7. See

[To see links please register here]

and

[To see links please register here]


However, you still can use PHP condition to check the path.
Try this (add a new condition and use php to add this. You will need php module enabled).
In the Rules that redirects users after logging in,

<?php
if (arg(0) == 'user' && arg(1) == 'reset'){
return FALSE;
}
else{
return TRUE;
}
?>

This will prevent the Rule from continuing if the path us user/reset/*.
Also, probably you will need the same condition with TRUE False exchanged in another Rule that redirects password-change users.
Reply

#3
You can do that with a rule like that:

{ "rules_after_login_redirect_to_news" : {
"LABEL" : "After login redirect to news.",
"PLUGIN" : "reaction rule",
"WEIGHT" : "0",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_login" ],
"IF" : [
{ "NOT text_matches" : {
"text" : [ "site:current-page:path" ],
"match" : "^user\/reset\/",
"operation" : "regex"
}
}
],
"DO" : [ { "redirect" : { "url" : "news" } } ]
}
}
Reply

#4
In the project I'm currently working on I encountered the same problem.
We solved it by using the Context module (

[To see links please register here]

).

Install and enable the Context module.
Create a context with the condition :
path = ~user/reset/*
(Leave reactions empty)

Use this context as an condition in the login redirect rule
(Context rules / is a context set)
Reply

#5
You can also fix this problem just using the module rules, no coding.

In my case I wanted to redirect people to their workbench after they login.
But people that forgot their password would also get redirected to their workbench and wouldn't be able to change their password. They had to navigate to their own profile page but they had to reenter their password again: the onetime logging didn't work anymore.

So this is the rule I added:

**Events**
Event: User logged in.

**Conditions**
Elements: Text comparison.
Parameter: Tekst: [site:current-page:path], Matching text: user, Comparison operation: ends with

**Actions**
Elements: Page redirect
Parameter: URL: admin/workbench, Force redirect: false
Reply

#6
I fixed this problem just using rules, as outlined in another answer here but i had to modify it to work, i had to set the Text comparison condition to negative, and the page redirect to Force redirect, and the page i wanted was called 'getting-started'. Works Perfect

So the rule i added:
**EVENTS**
User has logged in

**CONDITIONS**
NOT Text comparison
Parameter: Text: [site:current-page:path], Matching text: user, Comparison operation: starts with

**ACTIONS**
Page redirect
Parameter: URL: getting-started
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through