From d0d3b7457b54f4ce2672ae2dc3e725319e576235 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 18 Sep 2014 16:02:18 +0200 Subject: Move BasicAuth check to "isLoggedIn()" Ensures that Basic Auth works properly for APIs and removes the need for some even uglier lines of code. --- lib/private/user.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/private') diff --git a/lib/private/user.php b/lib/private/user.php index a79fc2ce834..641a329b0dd 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -335,15 +335,19 @@ class OC_User { } /** - * Check if the user is logged in + * Check if the user is logged in, considers also the HTTP basic credentials * @return bool - * - * Checks if the user is logged in */ public static function isLoggedIn() { if (\OC::$server->getSession()->get('user_id') !== null && self::$incognitoMode === false) { return self::userExists(\OC::$server->getSession()->get('user_id')); } + + // Check whether the user has authenticated using Basic Authentication + if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { + return \OC_User::login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); + } + return false; } -- cgit v1.2.3