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

Beispiel #1
0
 /**
  * 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