From 7e4f50d4e385e1d55b7839146a82dd48cb657c2a Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 22 Nov 2013 13:55:38 +0100 Subject: [PATCH 1/2] add incognito mode, allows to hide my user ID. For example, this is useful to access public resources while a user is still logged in --- lib/private/user.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/private/user.php b/lib/private/user.php index f15fdf1dbbc..5bd36006750 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -54,6 +54,9 @@ class OC_User { private static $_setupedBackends = array(); + // bool, stores if a user want to access a resource anonymously, e.g if he opens a public link + private static $incognitoMode = false; + /** * @brief registers backend * @param string $backend name of the backend @@ -319,6 +322,15 @@ class OC_User { return false; } + /** + * @brief set incognito mode, e.g. if a user wants to open a public link + * @param bool $status + */ + public static function setIncognitoMode($status) { + self::$incognitoMode = $status; + + } + /** * Supplies an attribute to the logout hyperlink. The default behaviour * is to return an href with '?logout=true' appended. However, it can @@ -354,7 +366,7 @@ class OC_User { */ public static function getUser() { $uid = OC::$session ? OC::$session->get('user_id') : null; - if (!is_null($uid)) { + if (!is_null($uid) && self::$incognitoMode === false) { return $uid; } else { return false; From 2cc0c90015aca5ea287dadd8c0edc3925a573426 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Fri, 22 Nov 2013 14:00:08 +0100 Subject: [PATCH 2/2] set incognito mode for public.php calls. Because in this case ownCloud should always work the same way as if no user is logged in --- public.php | 1 + 1 file changed, 1 insertion(+) diff --git a/public.php b/public.php index 1781632bc78..203372fe1ea 100644 --- a/public.php +++ b/public.php @@ -20,6 +20,7 @@ try { OC_Util::checkAppEnabled($app); OC_App::loadApp($app); + OC_User::setIncognitoMode(true); require_once OC_App::getAppPath($app) .'/'. $parts[1];