Validate a LogoutRequest NameId

@param LogoutRequest $request
@param User          $user

@throws SamlException
420142
public function validateNameId(LogoutRequest $request, User $user)
    {
        if ($request->getNameID()->getValue() != $user->getUserName()) {
            throw new SamlException('urn:oasis:names:tc:SAML:2.0:status:RequestDenied');
        }
    }
329391
public function logConnectPlatformListAction(User $user, Request $request)
    {
        $this->checkAdminToolAccess();
        $isAdmin = $this->authorization->isGranted('ROLE_ADMIN');
        $hiddenFilters = $isAdmin ?
            [] :
            ['hiddenFilters' => [
                'organizations' => array_map(function (Organization $organization) {
                    return $organization->getUuid();
                }, $user->getAdministratedOrganizations()->toArray()),
            ]];

        return new JsonResponse(
            $this->finder->search(LogConnectPlatform::class, array_merge(
                $request->query->all(),
                $hiddenFilters
            ))
        );
    }
1214743
public static function isAuthorized($user_id, Request $request) {

        /**
         * Authorize logout action for all authenticate user
         */
        if ($request->action === 'logout')
            return true;

        /**
         * Authorize login action for all authenticate user
         */
        if ($request->action === 'login')
            return true;

        /**
         * Authorize display action for all authenticate user
         */
        if ($request->action === 'display')
            return true;

        /**
         * Define $url_elements
         */
        $url_elements = explode('/', $request->url);

        /**
         * Find roles by $user_id
         */
        $usersTables = TableRegistry::get('Builder.Users');
        $query = $usersTables->find('all');
        $query->where(['id' => $user_id]);
        $query->contain(['Roles']);
        $roles = $query->first()->roles;

        /**
         * Define $userRolesId for passed $user_id
         */
        $userRolesId = [];
        foreach ($roles as $row)
            $userRolesId[$row->id] = true;

        /**
         * Find relative task in Builder.Tasks
         */
        $tasksTable = TableRegistry::get('Builder.Tasks');
        do {
            $route_target = '/' . implode('/', $url_elements);
            $query = $tasksTable->find('all');
            $query->where(['route' => $route_target]);
            $query->contain(['Roles']);
            $result = $query->first();

            /**
             * If user has roles authorized return true
             */
            if (count($result) > 0):
                foreach ($result->roles as $role):
                    if (array_key_exists($role->id, $userRolesId))
                        return true;
                endforeach;
            endif;

            /**
             * Remove the element off the end of array
             */
            array_pop($url_elements);
        } while ($route_target != '/');

        /**
         * Defualt value
         */
        return false;
    }
650051
public function postLogin (Request $request, \Neuron\Interfaces\Models\User $user, $registered = false)
    {
        $parameters = array();
        if ($registered) {
            $parameters['registered'] = 1;
        }

        // Also set in session... why wouldn't this be in session? :D
        $request->getSession()->set('userJustRegistered', $registered);

        $this->trigger('user:login', [
            'request' => $request,
            'user' => $user,
            'registered' => $registered
        ]);

        // Should skip welcome screen?
        if ($request->getSession()->get('skip-welcome-redirect')) {
            $redirectUrl = $this->getAndClearPostLoginRedirect($request);
            return Response::redirect($redirectUrl);
        }

        return $this->redirectToWelcome ([]);
    }
449568
public function switchUserStart(User $user, Request $request)
    {
        if (! session()->has('original_user')) {
            session()->put('original_user', $request->user()->id);
        }
        Auth::login($user);

        return back();
    }
249130
public function authenticated(Request $request, $user)
    {
        if ($user->is_blocked || ! $user->is_activated) {
            if ($user->is_blocked) {
                $message = 'Your account is currently banned from accessing the site!';
            } else {
                $message = 'Your account is not yet activated!';
            }
            $this->guard()->logout();
            flash()->error($message);

            return redirect()->route('administrator.login')->withErrors($message);
        }

        return redirect()->intended($this->redirectPath);
    }
751768
public function prepareLogoutResponse(LogoutRequest $request)
    {
        $response = $this->createLogoutResponse();

        $idp = $this->getMetadata()->getFirstIdpSsoDescriptor();

        $location = $idp->getFirstSingleLogoutService()->getResponseLocation()
            ? $idp->getFirstSingleLogoutService()->getResponseLocation()
            : $idp->getFirstSingleLogoutService()->getLocation();

        $response->setDestination($location);
        $response->setRelayState($request->getRelayState());

        $this->signMessage($response);

        return $response;
    }
425919
public function logoutUser(WebRequest $request, Response $response)
    {
        $this->cleanupSession($request);
        
        $request->removeSession();
    }
1301453
public function deleteAction(Request $request)
	{
		// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
		if (!$request->request->get('user_id')) {
			throw new CmsException(null, 'User id is not set');
		}

		$userId = $request->request->get('user_id');

		$currentUser = $this->getUser();
		$currentUserId = $currentUser->getId();

		if ($currentUserId == $userId) {
			throw new CmsException(null, 'You can\'t delete current user account');
		}

		$user = $this->container->getDoctrine()->getRepository('CmsAuthentication:User')->findOneById($userId);

		if (empty($user)) {
			throw new CmsException(null, 'Can\'t find user with such id');
		}

//		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME);

		$this->container->getDoctrine()->getManager()->remove($user);
		$this->container->getDoctrine()->getManager()->flush();

		return new SupraJsonResponse(null);
	}
38196
public function saveUser(User $user, Request $request)
    {
        $user->fill($request->get('user'))
            ->save();

        Alert::info(__('User was saved.'));

        return back();
    }
817555
private function loginUser(UserInterface $user, $request)
    {
        $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles());
        $this->get('security.token_storage')->setToken($token); //now the user is logged in

        //now dispatch the login event
        $event = new InteractiveLoginEvent($request, $token);
        $this->get('event_dispatcher')->dispatch('security.interactive_login', $event);
    }
1321612
protected function pullUsernameFromQuery(Request $request)
    {
        $queryUsername = $request->query->get('username');

        if ($queryUsername) {
            if (strlen($queryUsername) <= Security::MAX_USERNAME_LENGTH) {
                $request->getSession()
                    ->set(Security::LAST_USERNAME, $queryUsername);
            }
        }
    }
239683
public function handle(Logout $event)
    {
        if ($event->user) {
            $user = $event->user;
            $ip = $this->request->ip();
            $userAgent = $this->request->userAgent();
            $authenticationLog = $user->authentications()->whereIpAddress($ip)->whereUserAgent($userAgent)->first();

            if (! $authenticationLog) {
                $authenticationLog = new AuthenticationLog([
                    'ip_address' => $ip,
                    'user_agent' => $userAgent,
                ]);
            }

            $authenticationLog->logout_at = Carbon::now();

            $user->authentications()->save($authenticationLog);
        }
    }
820573
protected function processLogout(Request $request): void
    {
        auth()->guard($this->getGuard())->logout();

        $request->session()->invalidate();
    }
1139162
public function logout(Request $request)
    {
        $this->guard()->logout();

        $request->session()->invalidate();

        return redirect(route('admin.login'));
    }
1254276
public function getLogout(Request $request)
    {
        // Terminate the user's current session.  Passing true as the
        // second parameter kills all of the user's active sessions.
        $result = $this->authManager->logout(null, null);

        // Return the appropriate response
        return $result->dispatch(route('dashboard'));
    }
1022376
public function logout(Request $request)
    {
        $activeGuards = 0;
        $this->guard()->logout();

        foreach (config('auth.guards') as $guard => $guardConfig) {
            if ($guardConfig['driver'] === 'session') {
                if ($this->isActiveGuard($request, $guard)) {
                    $activeGuards++;
                }
            }
        }

        if ( ! $activeGuards) {
            $request->session()->flush();
            $request->session()->regenerate();
        }

        return redirect()->to($this->logoutToPath());
    }