Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Security/changepassword Redirect?


Reply


4 Posts   1947 Views

Avatar
Enclave SSC

Community Member, 31 Posts

27 January 2010 at 12:13am

Hi Guys

Security/changepassword upon completion redirects to Security/login. This is quite redundant as the user would already be logged in. Is there any wat to change this page to Redirect home for example. I attempted BackURL in the form action without joy.

Any assistance would be appreciated.

Avatar
joelg

Community Member, 129 Posts

30 June 2010 at 1:05am

Hi

You can make a custom class that extends ChangePasswordForm.php – and override the doChangePassword-function. Inside this function there is a line which redirects the user.

Joel

Avatar
DNA

Community Member, 24 Posts

11 January 2011 at 2:47pm

Actually currently (2.4.3) you can extend ChangePasswordForm and then use Object::useCustomClass as joel suggests, but it will not be picked up.

The above method works fine for MemberLoginForm as when that is called in MemberAuthenticator it uses Object::create instead of new MemberLoginForm.

The work around is to fix Security line 589 which in my opinion should use Object::create not new ChangePasswordForm.

However since its A VERY BAD IDEA TO EDIT THE CORE, simple create a new class called CustomSecurity which extends Security and then add a rule in mysite/config.php

Director::addRules(11, array(
   'Security//$Action/$ID/$OtherID' => 'CustomSecurity',
));

The rule above overrides the rule in Sapphire/_config because the priority is 11 which outranks 10.

http://open.silverstripe.org/ticket/6334

Avatar
DNA

Community Member, 24 Posts

11 January 2011 at 2:53pm

class CustomSecurity extends Security {

   /**
    * Factory method for the lost password form
    *
    * @return Form Returns the lost password form
    */
   public function ChangePasswordForm() {
      return Object::create('ChangePasswordForm', $this, 'ChangePasswordForm');
   }

}