21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1018 Views |
-
Redirect on Login Failure

1 May 2009 at 7:24am
I need to redirect the user to a registration form when they try to login and it fails.
How can I do this? I will apologize in advance bacause I'm technical, but have not educated myself on the whole php5 class concepts. So while I sort of understand it, I don't know enough to pull it off.
I know once I get it life will be much better, so I'm learning.
Has anyone done this when a user logs in and it fails?
Terry
-
Re: Redirect on Login Failure

2 May 2009 at 12:22pm
Hi Terry
If you look at my tutorial on Login redirection, in part II there is a CustomLogin function that looks like this:
class CustomLogin extends MemberLoginForm {
02. public function dologin($data) {
03. if($this->performLogin($data)) {
04. if(!$this->redirectByGroup($data))
05. Director::redirect(Director::baseURL());
06. } else {
07. if($badLoginURL = Session::get("BadLoginURL")) {
08. Director::redirect($badLoginURL);
09. } else {
10. Director::redirectBack();
11. }
12. }
13. }
14.}On line 07 - 11 you can see that on a bad login the user is directed to either the $BadLoginURL or if taht fails then just back. If you subclass the login in the way described by the tutorial you should be able to replace this bit of code with any URL you like and SS will prform the redirection if the login fails.
As a side note, I would be pretty annoyed if I was trying to login to a site and I mistyped my login (as often happens) and it then redirected me to a registration form instead of back to the login to try again.....just a thought
Hope that helps.
-
Re: Redirect on Login Failure

2 May 2009 at 12:48pm
aram,
Thank you for this. It works great.
Yeah, I agree with the registration form from a bad login. I tried to talk the client out of it but they probably have to see it first before they understand that it will be annoying.
Thanks again. My first SS site is started to have look very promising.
I appreciate your help.
Terry
| 1018 Views | ||
|
Page:
1
|
Go to Top |


