From 0537960dccb5e9ef7e87d383304e09858d54557b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 1 Oct 2013 22:56:47 +0200 Subject: [PATCH] adding getCurrentUserId() to ApacheBackend --- lib/public/apachebackend.php | 8 +++++++- lib/user.php | 9 ++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/public/apachebackend.php b/lib/public/apachebackend.php index 24e50ab616..47ee8b4ed3 100644 --- a/lib/public/apachebackend.php +++ b/lib/public/apachebackend.php @@ -38,4 +38,10 @@ interface ApacheBackend { */ public function getLogoutAttribute(); -} \ No newline at end of file + /** + * Return the id of the current user + * @return string + */ + public function getCurrentUserId(); + +} diff --git a/lib/user.php b/lib/user.php index e0b58e22c3..a4ad327814 100644 --- a/lib/user.php +++ b/lib/user.php @@ -219,14 +219,13 @@ class OC_User { * * Log in a user and regenerate a new session. */ - public static function loginWithApache() { + public static function loginWithApache(\OCP\ApacheBackend $backend) { - $uid = $_SERVER["PHP_AUTH_USER"]; + $uid = $backend->getCurrentUserId(); $run = true; OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid )); - $enabled = self::isEnabled($uid); - if($uid && $enabled) { + if($uid) { session_regenerate_id(true); self::setUserId($uid); self::setDisplayName($uid); @@ -253,7 +252,7 @@ class OC_User { self::setupBackends(); self::unsetMagicInCookie(); - if (self::loginWithApache()) { + if (self::loginWithApache($backend)) { if (! $isWebdav) { $_REQUEST['redirect_url'] = \OC_Request::requestUri(); OC_Util::redirectToDefaultPage();