mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
4a5d9b03f8
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@39001 467b73ca-7a2a-4603-9d3b-597d59a354a9
54 lines
1.4 KiB
PHP
Executable File
54 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Standard Change Password Form
|
|
*/
|
|
|
|
class ChangePasswordForm extends Form {
|
|
|
|
function __construct($controller, $name, $fields = null, $actions = null) {
|
|
|
|
if(!$fields) {
|
|
$fields = new FieldSet(
|
|
new EncryptField("OldPassword","Your old password"),
|
|
new EncryptField("NewPassword1", "New Password"),
|
|
new EncryptField("NewPassword2", "Confirm New Password")
|
|
);
|
|
}
|
|
if(!$actions) {
|
|
$actions = new FieldSet(
|
|
new FormAction("changePassword", "Change Password")
|
|
);
|
|
}
|
|
|
|
parent::__construct($controller, $name, $fields, $actions);
|
|
}
|
|
|
|
function changePassword($data){
|
|
if($member = Member::currentUser()){
|
|
if($data['OldPassword'] != $member->Password){
|
|
$this->clearMessage();
|
|
$this->sessionMessage("Your current password does not match, please try again", "bad");
|
|
Director::redirectBack();
|
|
}else if($data[NewPassword1] == $data[NewPassword2]){
|
|
$member->Password = $data[NewPassword1] ;
|
|
$member->sendinfo('changePassword');
|
|
$member->write();
|
|
$this->clearMessage();
|
|
$this->sessionMessage("Your password has been changed, and a copy emailed to you.", "good");
|
|
Director::redirectBack();
|
|
}
|
|
else{
|
|
$this->clearMessage();
|
|
$this->sessionMessage("Your have entered your new password differently, try again", "bad");
|
|
Director::redirectBack();
|
|
}
|
|
}
|
|
else {
|
|
Director::redirect('loginpage');
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
?>
|