Upgraded to KH 3.3.0
This commit is contained in:
38
includes/kohana/system/classes/Kohana/HTTP/Exception/401.php
Normal file
38
includes/kohana/system/classes/Kohana/HTTP/Exception/401.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php defined('SYSPATH') OR die('No direct script access.');
|
||||
|
||||
class Kohana_HTTP_Exception_401 extends HTTP_Exception_Expected {
|
||||
|
||||
/**
|
||||
* @var integer HTTP 401 Unauthorized
|
||||
*/
|
||||
protected $_code = 401;
|
||||
|
||||
/**
|
||||
* Specifies the WWW-Authenticate challenge.
|
||||
*
|
||||
* @param string $challenge WWW-Authenticate challenge (eg `Basic realm="Control Panel"`)
|
||||
*/
|
||||
public function authenticate($challenge = NULL)
|
||||
{
|
||||
if ($challenge === NULL)
|
||||
return $this->headers('www-authenticate');
|
||||
|
||||
$this->headers('www-authenticate', $challenge);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate this exception contains everything needed to continue.
|
||||
*
|
||||
* @throws Kohana_Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
if ($this->headers('www-authenticate') === NULL)
|
||||
throw new Kohana_Exception('A \'www-authenticate\' header must be specified for a HTTP 401 Unauthorized');
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user