From 94fb52459898989ea2158e6b90440632724a1679 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 10 Mar 2016 17:04:37 +0100 Subject: * password change form as a component --- app/php/components/PasswordChange.php | 34 ++++++++++++++++++++++ app/php/components/PasswordChange.tpl | 52 +++++++++++++++++++++++++++++++++ app/php/pages/Profile.page | 55 ++--------------------------------- app/php/pages/Profile.php | 24 --------------- 4 files changed, 89 insertions(+), 76 deletions(-) create mode 100644 app/php/components/PasswordChange.php create mode 100644 app/php/components/PasswordChange.tpl delete mode 100644 app/php/pages/Profile.php (limited to 'app/php') diff --git a/app/php/components/PasswordChange.php b/app/php/components/PasswordChange.php new file mode 100644 index 0000000..8aedcab --- /dev/null +++ b/app/php/components/PasswordChange.php @@ -0,0 +1,34 @@ +getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + $this->setControlState('user', $user); + } + + public function checkPassword($sender, $param) { + $param->IsValid = DbUser::verifyPassword( + $this->Password->Text, $this->UserToChange->DbRecord->Password + ); + } + + public function changePassword($sender, $param) { + $this->SuccessMessage->Visible = FALSE; + if ($this->Page->IsValid) { + $this->UserToChange->DbRecord->Password = DbUser::generatePassword( + $this->NewPassword->Text + ); + $this->UserToChange->DbRecord->save(); + $this->SuccessMessage->Visible = TRUE; + } + } + +} + +?> diff --git a/app/php/components/PasswordChange.tpl b/app/php/components/PasswordChange.tpl new file mode 100644 index 0000000..c1eb793 --- /dev/null +++ b/app/php/components/PasswordChange.tpl @@ -0,0 +1,52 @@ +Change password
+Current password: + + + +
+New password: + + +
+Repeat password: + + + +
+ + diff --git a/app/php/pages/Profile.page b/app/php/pages/Profile.page index 71ed112..b66a50b 100644 --- a/app/php/pages/Profile.page +++ b/app/php/pages/Profile.page @@ -1,54 +1,5 @@ - Change password
- Current password: - - - -
- New password: - - -
- Repeat password: - - - -
- - + + <%= $this->User %> +
diff --git a/app/php/pages/Profile.php b/app/php/pages/Profile.php deleted file mode 100644 index 6df87bc..0000000 --- a/app/php/pages/Profile.php +++ /dev/null @@ -1,24 +0,0 @@ -IsValid = DbUser::verifyPassword( - $this->Password->Text, $this->User->DbRecord->Password - ); - } - - public function changePassword($sender, $param) { - $this->SuccessMessage->Visible = FALSE; - if ($this->Page->IsValid) { - $this->User->DbRecord->Password = DbUser::generatePassword( - $this->NewPassword->Text - ); - $this->User->DbRecord->save(); - $this->SuccessMessage->Visible = TRUE; - } - } - -} - -?> -- cgit v1.2.3