public function login($username, $password, $rememberMe = false) { //TODO: Ashot implement user login rememberMe $user = $this->userDao->getUserByUsername($username); if (isset($user)) { if ($user->isPasswordEqual($password)) { $session = App::getSession(); $session->isLogged = true; } else { Notification::error(2, ''); //TODO: Armen Notification text for not correct password } } else { Notification::error(1, ''); //TODO: Armen Notification text for invalid username } return App::isLoggedUser(); }
public function updateUser(array $userData) { $user = new User($userData); $userId = $user->getUserId(); if (empty($userId)) { return Notification::error('UserId is empty'); } if (empty($user->getUserName())) { $user->setUserName('user' . App::getCounterNextIndex('user')); } $userTableUpdate = $this->db->update('users', $user->toArray(), 'userId = :userId', ['userId' => $userId]); if ($userTableUpdate) { switch ($user->getRole()) { case Defines::ROLE_DOCTOR: $doctor = new User($userData); return $this->db->update('doctors', $doctor->toArray(), 'doctorId = :userId', ['userId' => $userId]); case Defines::ROLE_CLIENT: $client = new User($userData); return $this->db->update('clients', $client->toArray(), 'clientId = :userId', ['userId' => $userId]); } } return false; }
public static function errorHandler($errno, $errstr, $errfile, $errline) { if (Config::getInstance()->environment != 'development') { return; } if ($errno == E_STRICT) { return; } $content = $errstr . "\n file " . $errfile . " line " . $errline; if (in_array($errno, self::$phpWarning)) { Notification::warning(1, $content, 'php_warning'); } else { Notification::error(1, $content, 'php_error'); } }