diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-18 16:02:18 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-09-18 16:14:07 +0200 |
commit | d0d3b7457b54f4ce2672ae2dc3e725319e576235 (patch) | |
tree | d1b0c971f45193017de6b00af1f94543b16bb312 /lib/private | |
parent | f0bf46b0809b9c301b25662f58c9ff76f369941c (diff) | |
download | nextcloud-server-d0d3b7457b54f4ce2672ae2dc3e725319e576235.tar.gz nextcloud-server-d0d3b7457b54f4ce2672ae2dc3e725319e576235.zip |
Move BasicAuth check to "isLoggedIn()"
Ensures that Basic Auth works properly for APIs and removes the need for some even uglier lines of code.
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/user.php | 10 |
1 files changed, 7 insertions, 3 deletions
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; } |