コード例 #1
0
 protected function processLogin(ChainContainer $chain)
 {
     $user = $chain->getFrom();
     $request = $chain->getRequest();
     $lang = $user->getLang();
     $logger = DI::get()->getLogger();
     if (!($userDAO = $this->validateLogin($request))) {
         RespondError::make($user, ['email' => $lang->getPhrase('InvalidLogin')]);
         return;
     }
     $oldUserId = $user->getId();
     $oldChannelId = $user->getChannelId();
     $clients = DI::get()->getUsers();
     if ($oldUserId == $userDAO->getId()) {
         RespondError::make($user, ['email' => $lang->getPhrase('AlreadyAuthorized')]);
         return;
     }
     if ($duplicatedUser = $clients->getClientById($userDAO->getId())) {
         if ($timer = $duplicatedUser->getDisconnectTimer()) {
             DI::get()->container()->get('eventloop')->cancelTimer($timer);
             $logger->info("Deffered disconnection timer canceled: " . "connection_id = {$duplicatedUser->getConnectionId()} for userId = {$duplicatedUser->getId()}");
         }
         $duplicatedUser->setAsyncDetach(false)->send(['msg' => $lang->getPhrase('DuplicateConnection'), 'disconnect' => 1]);
         Chat::get()->onClose($duplicatedUser->getConnection());
     }
     $userDAO->setChatId($oldChannelId);
     $user->setUserDAO($userDAO);
     $clients->updateKeyOfUserId($oldUserId);
     DI::get()->getSession()->updateSessionId($user, $oldUserId);
     $logger->info("LoginController::login success for " . $user->getId());
     $this->sendNotifyResponse($user);
     $responseFilter = new ResponseFilter();
     $responseFilter->sendNickname($user, $clients);
     $responseFilter->notifyChat($user, $clients);
 }
コード例 #2
0
ファイル: Kick.php プロジェクト: jackblackjack/sociochat
 public function run(User $user, $args)
 {
     $text = explode(' ', $args, 2);
     $assHoleName = $text[0];
     $users = DI::get()->getUsers();
     if (!($assHole = $users->getClientByName($assHoleName))) {
         return ["{$assHoleName} not found", 1];
     }
     $userDAO = $assHole->getUserDAO()->setBanned(true);
     $userDAO->save(false);
     $assHole->setAsyncDetach(false)->send(['disconnect' => 1, 'msg' => isset($text[1]) ? $text[1] : null]);
     Chat::get()->onClose($assHole->getConnection());
     return ["{$assHoleName} кикнут", false];
 }