예제 #1
0
 protected function buildIdentity($userID)
 {
     $userData = $this->usersModel->get($userID);
     if (!$userData) {
         throw new \Nette\Security\AuthenticationException('Neexistují odpovídající data o uživateli.', self::FAILURE);
     }
     unset($userData->id);
     $membershipData = $this->membershipModel->query("SELECT `group`.* FROM membership JOIN `group` ON `group`.id = membership.group_id WHERE membership.user_id = " . $userID)->fetchAll();
     $roles = array();
     foreach ($membershipData as $record) {
         $roles[] = $record->role_name;
     }
     return new \Nette\Security\Identity($userID, $roles, $userData);
 }
예제 #2
0
 protected function buildIdentity($userID)
 {
     $userData = $this->usersModel->get($userID);
     if (!$userData) {
         throw new \Nette\Security\AuthenticationException('Neexistují odpovídající data o uživateli.', self::FAILURE);
     }
     unset($userData->id);
     $membershipData = $this->membershipModel->query("SELECT `group`.* FROM membership JOIN `group` ON `group`.id = membership.group_id WHERE membership.user_id = " . $userID)->fetchAll();
     $roles = array();
     foreach ($membershipData as $record) {
         $roles[] = $record->role_name;
     }
     $settings = $this->usersModel->query("SELECT * FROM `user_setting` WHERE user_id = {$userID}")->fetch();
     if (!$settings) {
         $this->usersModel->query("INSERT INTO `user_setting` (`user_id`) VALUES ({$userID})");
         $settings = $this->usersModel->query("SELECT * FROM `user_setting` WHERE user_id = {$userID}")->fetch();
     }
     $settings = $settings->toArray();
     unset($settings["user_id"]);
     $userData["settings"] = $settings;
     return new \Nette\Security\Identity($userID, $roles, $userData);
 }