diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-12-08 20:47:55 -0800 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-12-08 20:47:55 -0800 |
commit | 0f4ceedbb492126dcbbbcd77b5252816097d2857 (patch) | |
tree | 6d2497d791f1b864e50805ea9b2a32483989746a | |
parent | 656e5fd052d0ee1e9161e25090b54be70d4880ba (diff) | |
download | volse-hubzilla-0f4ceedbb492126dcbbbcd77b5252816097d2857.tar.gz volse-hubzilla-0f4ceedbb492126dcbbbcd77b5252816097d2857.tar.bz2 volse-hubzilla-0f4ceedbb492126dcbbbcd77b5252816097d2857.zip |
remove duplicated code
-rw-r--r-- | include/api_auth.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/include/api_auth.php b/include/api_auth.php index b78c69bac..cabaed93e 100644 --- a/include/api_auth.php +++ b/include/api_auth.php @@ -54,10 +54,7 @@ function api_login(&$a){ if (!isset($_SERVER['PHP_AUTH_USER'])) { logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG); - header('WWW-Authenticate: Basic realm="Red"'); - header('HTTP/1.0 401 Unauthorized'); - echo('This api requires login'); - killme(); + retry_basic_auth(); } // process normal login request @@ -80,10 +77,7 @@ function api_login(&$a){ } if(! $record) { logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); - header('WWW-Authenticate: Basic realm="Red"'); - header('HTTP/1.0 401 Unauthorized'); - echo('This api requires login'); - killme(); + retry_basic_auth(); } } @@ -95,3 +89,11 @@ function api_login(&$a){ $_SESSION['allow_api'] = true; } + + +function retry_basic_auth() { + header('WWW-Authenticate: Basic realm="Hubzilla"'); + header('HTTP/1.0 401 Unauthorized'); + echo('This api requires login'); + killme(); +}
\ No newline at end of file |