summaryrefslogtreecommitdiff
path: root/app/php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-03-16 22:56:55 +0100
committeremkael <emkael@tlen.pl>2016-03-16 22:56:55 +0100
commit51c2c559ecf853583b44145a9e06799c434d5c59 (patch)
tree2ff6644b0ebf382edaf4f7aea84146497ece3339 /app/php
parent75dc7a1df808ab2ca93ca96e299b06d90ebcedf6 (diff)
* password change/retrieval refactoring
Diffstat (limited to 'app/php')
-rw-r--r--app/php/components/PasswordChange.php5
-rw-r--r--app/php/user/DbUser.php13
2 files changed, 15 insertions, 3 deletions
diff --git a/app/php/components/PasswordChange.php b/app/php/components/PasswordChange.php
index 1224f33..9f2ac7f 100644
--- a/app/php/components/PasswordChange.php
+++ b/app/php/components/PasswordChange.php
@@ -19,17 +19,16 @@ class PasswordChange extends TTemplateControl {
public function checkPassword($sender, $param) {
$param->IsValid = DbUser::verifyPassword(
- $this->Password->Text, $this->UserToChange->DbRecord->Password
+ $this->Password->Text, $this->UserToChange->getPassword()
);
}
public function changePassword($sender, $param) {
$this->SuccessMessage->Visible = FALSE;
if ($this->Page->IsValid) {
- $this->UserToChange->DbRecord->Password = DbUser::generatePassword(
+ $this->UserToChange->changePassword(
$this->NewPassword->Text
);
- $this->UserToChange->DbRecord->save();
$this->SuccessMessage->Visible = TRUE;
}
}
diff --git a/app/php/user/DbUser.php b/app/php/user/DbUser.php
index 730a1c0..f9c8660 100644
--- a/app/php/user/DbUser.php
+++ b/app/php/user/DbUser.php
@@ -72,6 +72,19 @@ class DbUser extends TDbUser {
return new TimezoneDTO(date_default_timezone_get());
}
+ public function changePassword($pass) {
+ if (!$this->IsGuest) {
+ $this->DbRecord->Password = self::generatePassword($pass);
+ $this->DbRecord->save();
+ }
+ }
+
+ public function getPassword() {
+ if (!$this->IsGuest) {
+ return $this->DbRecord->Password;
+ }
+ }
+
public static function generatePassword($password) {
return password_hash($password, PASSWORD_DEFAULT);
}