Exemplo n.º 1
0
 public function onOpen(ConnectionInterface $conn)
 {
     // Store the new connection to send messages to later
     $this->clients->attach($conn);
     $session = (new SessionManager(App::getInstance()))->driver();
     $cookies = $conn->WebSocket->request->getCookies();
     $laravelCookie = urldecode($cookies[Config::get('session.cookie')]);
     $idSession = Crypt::decrypt($laravelCookie);
     $session->setId($idSession);
     $session->start();
     $userId = $session->get(Auth::getName());
     $user = User::find($userId);
     $conn->userId = $userId;
     $conn->isAdmin = $user->is_admin === true;
     echo "New connection! ({$conn->resourceId}), {$userId}\n";
 }
Exemplo n.º 2
0
 /**
  * Méthode de déconnection à la main de l'utilisateur
  * Il est retiré de la session et redirigé vers l'accueil
  *
  * @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector
  */
 public function logout()
 {
     Session::forget(Auth::getName());
     return redirect($this->redirectAfterLogout, 302, [], true);
 }