From 823d71ced9b4947b1a5a5ade7245d521ed490061 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 7 Jun 2016 15:17:49 +0200 Subject: * renaming php directory --- app/frontend/user/DbUser.php | 60 ++++++++++++++++++++++++++++++++++++++++++++ app/frontend/user/config.xml | 9 +++++++ 2 files changed, 69 insertions(+) create mode 100644 app/frontend/user/DbUser.php create mode 100644 app/frontend/user/config.xml (limited to 'app/frontend/user') diff --git a/app/frontend/user/DbUser.php b/app/frontend/user/DbUser.php new file mode 100644 index 0000000..d636e8b --- /dev/null +++ b/app/frontend/user/DbUser.php @@ -0,0 +1,60 @@ +_record = $record; + } + + public function getDbRecord() { + if (!$this->_record) { + $this->_record = UserFacade::getInstance()->findByLogin($this->Name); + } + return $this->_record; + } + + public function createUser($username) { + $dbUser = UserFacade::getInstance()->findByLogin($username); + if (!$dbUser) { + return NULL; + } + $user = new DbUser($this->Manager); + $user->setDbRecord($dbUser); + $user->Name = $dbUser->Login; + if ($dbUser->IsAdmin) { + $user->Roles = 'Admin'; + } + $user->IsGuest = FALSE; + return $user; + } + + public function validateUser($login, $password) { + $user = UserFacade::getInstance()->findByLogin($login); + $dbPassword = $user ? $user->Password : ''; + if (UserFacade::getInstance()->verifyPassword($password, $dbPassword) + && $user) { + $user->LastLogin = date('Y-m-d H:i:s'); + $user->save(); + return TRUE; + } else { + return FALSE; + } + } + + public function __call($name, $args) { + $match = []; + if (preg_match('/^getIs(.+)$/', $name, $match)) { + return $this->isInRole($match[1]); + } + throw new Exception('Unimplemented CustomDbUser method'); + } + +} + +?> diff --git a/app/frontend/user/config.xml b/app/frontend/user/config.xml new file mode 100644 index 0000000..80027e5 --- /dev/null +++ b/app/frontend/user/config.xml @@ -0,0 +1,9 @@ + + + + + + + -- cgit v1.2.3