From b9492c67c548345d723fe9dd6c238b6c9f1a48a2 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 18 Oct 2007 23:41:30 +0000 Subject: [PATCH] #1457 - Redirection after login doesn't behave correctly if login fails git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.1.1@43599 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- security/LoginForm.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/security/LoginForm.php b/security/LoginForm.php index b9d6f4bfb..4beaf2dc8 100644 --- a/security/LoginForm.php +++ b/security/LoginForm.php @@ -19,7 +19,7 @@ class LoginForm extends Form { $fields = new FieldSet( new TextField("Email", "Email address", Session::get('SessionForms.LoginForm.Email')), new EncryptField("Password", "Password"), - new CheckboxField("Remember", "Remember me next time?",true) + new CheckboxField("Remember", "Remember me next time?", true) ); } if(!$actions) { @@ -46,17 +46,21 @@ class LoginForm extends Form { } public function dologin($data) { - if($this->performLogin($data)){ + if($this->performLogin($data)) { if(isset($_REQUEST['BackURL']) && $backURL = $_REQUEST['BackURL']) { Session::clear("BackURL"); Director::redirect($backURL); - }else + } else { Director::redirectBack(); - }else{ + } + } else { + if(isset($_REQUEST['BackURL']) && $backURL = $_REQUEST['BackURL']) { + Session::set('BackURL', $backURL); + } - if($badLoginURL = Session::get("BadLoginURL")){ + if($badLoginURL = Session::get("BadLoginURL")) { Director::redirect($badLoginURL); - }else{ + } else { Director::redirectBack(); } }