summaryrefslogtreecommitdiff
path: root/app/php/user/DbUser.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-06 15:40:50 +0200
committeremkael <emkael@tlen.pl>2016-05-06 15:40:50 +0200
commita43e887c380fc414121792658136a34051526b6a (patch)
tree1816ec713671d02dd3d24e92c2f4675f7deab30d /app/php/user/DbUser.php
parent5bfe174b5907440a4f08bd45fd9c384ab5c58037 (diff)
* DbUser refactored to use a facade
Diffstat (limited to 'app/php/user/DbUser.php')
-rw-r--r--app/php/user/DbUser.php64
1 files changed, 3 insertions, 61 deletions
diff --git a/app/php/user/DbUser.php b/app/php/user/DbUser.php
index 7e6096c..ce4da4c 100644
--- a/app/php/user/DbUser.php
+++ b/app/php/user/DbUser.php
@@ -2,8 +2,7 @@
Prado::using('System.Security.TDbUserManager');
Prado::using('Application.model.User');
-Prado::using('Application.model.Calendar');
-Prado::using('Application.dto.TimezoneDTO');
+Prado::using('Application.facades.UserFacade');
class DbUser extends TDbUser {
@@ -38,7 +37,8 @@ class DbUser extends TDbUser {
public function validateUser($login, $password) {
$user = User::finder()->findByLogin($login);
$dbPassword = $user ? $user->Password : '';
- if (self::verifyPassword($password, $dbPassword) && $user) {
+ if (UserFacade::getInstance()->verifyPassword($password, $dbPassword)
+ && $user) {
$user->LastLogin = date('Y-m-d H:i:s');
$user->save();
return TRUE;
@@ -55,64 +55,6 @@ class DbUser extends TDbUser {
throw new Exception('Unimplemented CustomDbUser method');
}
- public function getCalendarPreference() {
- if ($this->IsGuest) {
- return Calendar::finder()->findAllByIsVisible(1);
- } else {
- return $this->DbRecord->Calendars;
- }
- }
-
- public function isCalendarPreferred($calendarID) {
- return in_array(
- $calendarID,
- array_map(
- function($calendar) {
- return $calendar->UID;
- },
- $this->getCalendarPreference()
- )
- );
- }
-
- public function setTimezonePreference($timezone) {
- if ($this->IsGuest) {
- throw new TInvalidDataException('Timezone preference change impossible for guest user');
- }
- $this->DbRecord->Timezone = $timezone;
- $this->DbRecord->save();
- }
-
- public function getTimezonePreference() {
- if (!$this->IsGuest) {
- try {
- return new TimezoneDTO($this->DbRecord->Timezone);
- } catch(Exception $e) {}
- }
- 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);
- }
-
- public static function verifyPassword($password, $dbPassword) {
- return password_verify($password, $dbPassword);
- }
-
}
?>