Return the valid authentication response.

@param  \Illuminate\Http\Request  $request
@param  mixed  $result
@return mixed
549485
public function validAuthenticationResponse($request, $result)
    {
        if (is_bool($result)) {
            return json_encode($result);
        }

        return json_encode(['channel_data' => [
            'user_id' => $request->user()->getKey(),
            'user_info' => $result,
        ]]);
    }
1160138
public function getOAuthAction(Request $request)
    {
        $this->initSession($request);

        $hash = md5(join("_", $request->request->all()) . uniqid());
        $this->sessionBag->set("hash", $hash);

        return $this->redirect(
            $this->getOAuthUrl($this->getCallbackUrl($request), $this->getClientId(), $hash),
            302,
            $this->defaultResponseHeaders
        );
    }
1113445
public function validAuthenticationResponse($request, $result)
    {
        if (Str::startsWith($request->channel_name, 'private')) {
            return $this->decodePusherResponse(
                $request, $this->pusher->socket_auth($request->channel_name, $request->socket_id)
            );
        }

        $channelName = $this->normalizeChannelName($request->channel_name);

        return $this->decodePusherResponse(
            $request,
            $this->pusher->presence_auth(
                $request->channel_name, $request->socket_id,
                $this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
            )
        );
    }
543193
public function check(Request $request, Response $response) {
        $actual = $request->getStage('g-recaptcha-response');
        $config = $this->app->package('global')->service('captcha-main');

        //if no config
        if(!$config
            || !isset($config['token'], $config['secret'])
            || $config['token'] === '<GOOGLE CAPTCHA TOKEN>'
            || $config['secret'] === '<GOOGLE CAPTCHA SECRET>'
        )
        {
            //let it pass
            $this->app->subflow($this->yes, $request, $response);
            return $this;
        }

        $result = CurlHandler::i()
            ->setUrl(self::END_POINT)
            ->verifyHost(false)
            ->verifyPeer(false)
            ->setPostFields(http_build_query(array(
                'secret' => $config['secret'],
                'response' => $actual
            )))
            ->getJsonResponse();

        if(!isset($result['success']) || !$result['success']) {
            //prepare to error
            $message = $this->app->package('global')->translate(static::ATTACK);
            $response->setError(true, $message);

            //and trigger a subflow
            $this->app->subflow($this->no, $request, $response);
            return $this;
        }

        //it passed
        $this->app->subflow($this->yes, $request, $response);
        return $this;
    }
739659
protected function getResponse( $result )
    {
        $this->response
             ->setContent( xmlrpc_encode_request(
                    null, $result,
                    array( 'encoding' => 'utf-8' )
                ) );

        return $this->response;
    }
698876
protected function authenticateExternalMember($data, ValidationResult &$result = null, Member $member = null)
    {
        $result = $result ?: ValidationResult::create();

        $ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');

        $email = !empty($data['Email']) ? $data['Email'] : null;

        if ($email != $ssLoginUserName) {
            return;
        }

        // Check for default admin user
        $member = Member::get()->find(
            Member::config()->get('unique_identifier_field'),
            $ssLoginUserName
        );

        if (!$member) {
            return;
        }

        $member->checkLoginPassword($data['Password'], $result);
        return $member;
    }
745349
public function postReset(Request $request) {

        $this->validate($request, [
            'token'    => 'required',
            'email'    => 'required|email',
            'password' => 'required|confirmed|min:6',
        ]);

        $credentials = $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );

        $response = Password::reset($credentials, function ($user, $password) {
            $this->resetPassword($user, $password);
        });

        switch ($response)
        {
            case Password::PASSWORD_RESET:
                //return redirect($this->redirectPath())->with('status', trans($response));
                return view('usermanagement::frontend.'.$this->frontend_template_name.'.password.password_reset_confirmation', [
                    'title'     => 'Password Reset Confirmed',
                    'email'     => $request->input('email'),
                    'username'  => Auth::user()->name,
                ]);

            default:
                return redirect()->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
        }
    }
621155
public function validAuthenticationResponse(Request $request, $result)
    {
        $channel = $request->input('channel_name');

        $socketId = $request->input('socket_id');

        if (Str::startsWith($channel, 'presence-')) {
            $user = $request->user();

            return $this->presenceAuth(
                $channel, $socketId, $user->getAuthIdentifier(), $result
            );
        }

        return $this->socketAuth($channel, $socketId);
    }
165701
public function postReset(Request $request)
	{
		$this->validate($request, [
			'token' => 'required',
			'email' => 'required|email',
			'password' => 'required|confirmed',
		]);

		$credentials = $request->only(
			'email', 'password', 'password_confirmation', 'token'
		);

		$response = $this->passwords->reset($credentials, function($user, $password)
		{
			$user->password = bcrypt($password);

			$user->save();

			$this->auth->login($user);
		});

		switch ($response)
		{
			case PasswordBroker::PASSWORD_RESET:
				return redirect($this->redirectPath());

			default:
				return redirect()->back()
							->withInput($request->only('email'))
							->withErrors(['email' => trans($response)]);
		}
	}
1117015
public function getResponse(Response $response, Request $request)
    {
        $this->prepareSearch($request);
        $this->preparePaging($request);
        $this->prepareOrder($request);

        $data = [];
        /** @var $entity Entity */
        foreach ($this->query as $entity) {
            $row = [];
            foreach ($this->table->getColumns() as $column) {
                if ($column instanceof ColumnInterface) {
                    $row[$column->getData()] = $column->getContent($entity);
                    continue;
                }

                $property = $this->getProperty($column->getData());
                $columnData = explode('.', $column->getData());
                $tableAlias = $columnData[0];
                $colName = $columnData[1];

                /**
                 * If property is association
                 */
                if (is_array($property)) {
                    if (is_callable($column->getFormatter())) {
                        $row[$tableAlias][$colName] = $this->doFormatter(
                            $column->getFormatter(),
                            [
                                $entity->get($property['propertyPath']) instanceof Entity ?
                                    $entity->get($property['propertyPath'])->get($property['field']) :
                                    $entity->get($property['propertyPath']),
                                $entity,
                                $entity->get($property['propertyPath'])
                            ]
                        );
                    } else {
                        if ($entity->get($property['propertyPath']) instanceof Entity) {
                            $row[$tableAlias][$colName] =
                                (string)$entity->get($property['propertyPath'])->get($property['field']);
                            /**
                             * BelongsToMany Association
                             */
                        } elseif (is_array($entity->get($property['propertyPath']))) {
                            $output = [];
                            /** @var Entity $belongsToManyEntity */
                            foreach ($entity->get($property['propertyPath']) as $belongsToManyEntity) {
                                $output[] = $belongsToManyEntity->get($property['field']);
                            }

                            $row[$tableAlias][$colName] = implode(', ', $output);
                        }
                    }
                } else {
                    if (is_callable($column->getFormatter())) {
                        $row[$tableAlias][$colName] = $this->doFormatter(
                            $column->getFormatter(),
                            [$entity->get($property), $entity]
                        );
                    } else {
                        $row[$tableAlias][$colName] = (string)$entity->get($property);
                    }
                }
            }
            $data[] = $row;
        }

        $response->setDraw($request->getDraw())
            ->setRecordsTotal($this->clonedQuery->count())
            ->setRecordsFiltered(self::$countBeforePaging)
            ->setData($data);
    }
450041
public function authenticate()
    {
        /* @var $user \Grid\User\Model\User\Structure */
        $user = $this->getModel()
                     ->findByEmail( $this->email );

        if ( empty( $user ) )
        {
            return new Result( Result::FAILURE_IDENTITY_NOT_FOUND, null );
        }

        if ( ! $user->isActive() ||
             ! $user->verifyPassword( $this->password, true ) )
        {
            return new Result( Result::FAILURE_CREDENTIAL_INVALID, null );
        }

        return new Result( Result::SUCCESS, $user );
    }
809838
protected function filterResult(Result $result)
    {
        $request = $result->getData('request') ?: array();
        foreach (array('AccountNumber', 'RoutingNumber') as $key) {
            if (array_key_exists($key, $request)) {
                $request[$key] = '[filtered]';
            }
        }

        $result->setData('request', $request);

        return $result;
    }
161700
protected function sendFailedLoginResponse(Request $request)
    {
        $credentials = $this->credentials($request);

        $user = User::where('email', $credentials['email'])->first();
        if (!$user) {
            $error = __('This user was not found.');
        } elseif (!$user->activated) {
            $error = __('This user is not activated.');
        } else {
            $error = __('The password is incorrect.');
        }

        $errors = [$this->username() => $error];

        if ($request->expectsJson()) {
            return response()->json($errors, 422);
        }

        return redirect()->back()
            ->withInput($request->only($this->username(), 'remember'))
            ->withErrors($errors);
    }
1148175
public function authenticate(Request $request)
    {
        return $request->get('username') === $this->username
            && password_verify($request->get('password'), $this->password);
    }
1137019
private function throwExceptionIfRequestRequiresAuthenticationOrReturnResponse(
        string $method,
        Request $request,
        Response $response
    ): Response {
        if ($response->statusCode() === Response::FORBIDDEN) {
            throw new AuthenticationRequiredException(
                sprintf(
                    'Request to "%s %s" requires authentication."',
                    $method,
                    $request->url()
                )
            );
        }

        return $response;
    }
1186989
protected function _authenticateValidateResult($resultIdentity)
    {
        $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match');

        if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') {
            $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
            $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
            return $this->_authenticateCreateAuthResult();
        }

        unset($resultIdentity[$zendAuthCredentialMatchColumn]);
        $this->_resultRow = $resultIdentity;

        $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
        $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
        return $this->_authenticateCreateAuthResult();
    }
1367292
public function postAction(Request $request): View
    {
        $this->validateCreateRequest($request);
        $administrator = $this->administratorRepository->findOneByLoginCredentials(
            $request->get('login_name'),
            $request->get('password')
        );
        if ($administrator === null) {
            throw new UnauthorizedHttpException('', 'Not authorized', null, 1500567098);
        }

        $token = $this->createAndPersistToken($administrator);

        return View::create()->setStatusCode(Response::HTTP_CREATED)->setData($token);
    }