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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

Security/changepassword Redirect?


Go to End


4 Posts   2996 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, 134 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');
	}

}