Skip to content
Permalink
Browse files

local variable optimization

  • Loading branch information...
nicolabeghin committed Mar 15, 2017
1 parent 089a0ae commit 74f700882c22e61cd62df56de5230ce853296e13
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
@@ -83,8 +83,9 @@ public function authenticate(CakeRequest $request, CakeResponse $response) {
*/
public function getUser(CakeRequest $request) {
if(!isset($_SERVER['PHP_AUTH_USER'])) {
if ($request->header('Authorization') !== false && strlen($request->header('Authorization')) > 0 && strpos($request->header('Authorization'), 'basic') !== false) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($request->header('Authorization'), 6)));
$httpAuthorization = $request->header('Authorization');
if ($httpAuthorization !== false && strlen($httpAuthorization) > 0 && strpos($httpAuthorization, 'basic') !== false) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($httpAuthorization, 6)));
if(strlen($_SERVER['PHP_AUTH_USER']) === 0 || strlen($_SERVER['PHP_AUTH_PW']) === 0) {
unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
}

0 comments on commit 74f7008

Please sign in to comment.
You can’t perform that action at this time.