mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
@@ -39,8 +39,15 @@ class Request {
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUser() {
|
||||
$data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST']);
|
||||
return (isset($data['username'])) ? $data['username'] : null;
|
||||
return (isset($_SERVER['PHP_AUTH_USER'])) ? $_SERVER['PHP_AUTH_USER']: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get http basic auth password
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPassword() {
|
||||
return (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW']: null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,4 +29,9 @@ class Response {
|
||||
$this->redirect(url());
|
||||
}
|
||||
|
||||
public function auth($name = '') {
|
||||
header('WWW-Authenticate: Basic realm="' . $name . '"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user