コード例 #1
0
 /**
  * Connect a user from $_POST values and return the result of the process as a JSON
  */
 public function connect()
 {
     try {
         $userManager = new UserManager();
         $this->JsonResponse($userManager->connect($_POST));
         unset($_POST);
     } catch (Exception $e) {
     }
 }
コード例 #2
0
 /**
  * Simply redirect kibana to its own localhost homepage
  */
 public function index()
 {
     if (isset($_SESSION['user'])) {
         $userManager = new UserManager(unserialize($_SESSION['user']));
         if ($userManager->hasKibanaRight()) {
             echo file_get_contents('http://127.0.0.1:5601');
         } else {
             goto Unauthorized;
         }
     } else {
         Unauthorized:
         header('HTTP/1.1 401 Unauthorized');
         // @todo check if Apache can serve custom page response on HTTP error code
         echo file_get_contents('../static/html/401Unauthorized.html');
     }
 }
コード例 #3
0
 /**
  * Determine if the client has room ban right
  *
  * @param      Client  $client  The client to check the right on
  *
  * @return     bool    True if the client has room ban right, false otherwise
  */
 public function hasBanRight(Client $client) : bool
 {
     $userManager = new UserManager($client->getUser());
     return $userManager->hasRoomBanRight($this->room);
 }
コード例 #4
0
ファイル: Orm.php プロジェクト: ZiperRom1/awesomeChatRoom
 /**
  * Insert users in database
  */
 private function insertUserData()
 {
     $users = new UserCollection();
     $userManager = new UserManager(null, $users);
     $password = crypt('123', Ini::getParam('User', 'passwordCryptSalt'));
     static::out('Create user data' . PHP_EOL);
     // Create an admin with password = 123
     $admin = new User(['id' => 1, 'email' => '*****@*****.**', 'firstName' => 'Admin', 'lastName' => 'God', 'pseudonym' => 'admin', 'password' => $password]);
     $admin->setRight(new UserRight(['idUser' => 1, 'webSocket' => 1, 'chatAdmin' => 1, 'kibana' => 1]));
     $users->add($admin);
     // Create some normal users with password = 123
     for ($i = 1; $i < 11; $i++) {
         $user = new User(['id' => $i + 1, 'email' => 'user_' . $i . '@websocket.com', 'firstName' => 'User ' . $i, 'lastName' => 'Normal', 'pseudonym' => 'User ' . $i, 'password' => $password]);
         $users->add($user);
     }
     if ($userManager->saveUserCollection()) {
         static::ok(sprintf('The followings users are inserted %s' . PHP_EOL, $users));
     } else {
         static::fail('An error occurred on user collection save' . PHP_EOL);
     }
 }