Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Security/changepassword Redirect?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1874 Views
  • Enclave SSC
    Avatar
    Community Member
    31 Posts

    Security/changepassword Redirect? Link to this post

    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.

  • joelg
    Avatar
    Community Member
    129 Posts

    Re: Security/changepassword Redirect? Link to this post

    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

  • DNA
    Avatar
    Community Member
    24 Posts

    Re: Security/changepassword Redirect? Link to this post

    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

  • DNA
    Avatar
    Community Member
    24 Posts

    Re: Security/changepassword Redirect? Link to this post

    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');
       }

    }

    1874 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.