Cartalyst\Sentinel\Sentinel::getBasicResponse PHP Method

getBasicResponse() public method

Sends a response when HTTP basic authentication fails.
public getBasicResponse ( ) : mixed
return mixed
    public function getBasicResponse()
    {
        // Default the basic response
        if ($this->basicResponse === null) {
            $this->basicResponse = function () {
                if (headers_sent()) {
                    throw new RuntimeException('Attempting basic auth after headers have already been sent.');
                }
                header('WWW-Authenticate: Basic');
                header('HTTP/1.0 401 Unauthorized');
                echo 'Invalid credentials.';
                exit;
            };
        }
        $response = $this->basicResponse;
        return $response();
    }

Usage Example

コード例 #1
0
ファイル: Security.php プロジェクト: digbang/security
 /**
  * Sends a response when HTTP basic authentication fails.
  *
  * @return mixed
  * @throws \RuntimeException
  */
 public function getBasicResponse()
 {
     return $this->sentinel->getBasicResponse();
 }
All Usage Examples Of Cartalyst\Sentinel\Sentinel::getBasicResponse