Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-10-02 17:31:46 +0400
committerAndreas Fischer <bantu@owncloud.com>2013-10-07 14:26:25 +0400
commit47ed6a5135dd1c6bc01169f430ebb243e29f2694 (patch)
treeda735d309bb98e22c85be334244ff4f7169893a4 /lib/private/user.php
parent131d82e41e2fee1d296687bdbba3c9ad50e979a6 (diff)
Move backend finding into its own method.
Diffstat (limited to 'lib/private/user.php')
-rw-r--r--lib/private/user.php42
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/private/user.php b/lib/private/user.php
index 0284e8044f6..04cd06b08bd 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -247,18 +247,15 @@ class OC_User {
* null: not handled / no backend available
*/
public static function handleApacheAuth() {
- foreach (self::$_usedBackends as $backend) {
- if ($backend instanceof OCP\Authentication\IApacheBackend) {
- if ($backend->isSessionActive()) {
- OC_App::loadApps();
+ $backend = self::findFirstActiveUsedBackend();
+ if ($backend) {
+ OC_App::loadApps();
- //setup extra user backends
- self::setupBackends();
- self::unsetMagicInCookie();
+ //setup extra user backends
+ self::setupBackends();
+ self::unsetMagicInCookie();
- return self::loginWithApache($backend);
- }
- }
+ return self::loginWithApache($backend);
}
return null;
@@ -319,12 +316,9 @@ class OC_User {
* @return string with one or more HTML attributes.
*/
public static function getLogoutAttribute() {
- foreach (self::$_usedBackends as $backend) {
- if ($backend instanceof OCP\Authentication\IApacheBackend) {
- if ($backend->isSessionActive()) {
- return $backend->getLogoutAttribute();
- }
- }
+ $backend = self::findFirstActiveUsedBackend();
+ if ($backend) {
+ return $backend->getLogoutAttribute();
}
return "href=" . link_to('', 'index.php') . "?logout=true";
@@ -568,4 +562,20 @@ class OC_User {
public static function unsetMagicInCookie() {
self::getUserSession()->unsetMagicInCookie();
}
+
+ /**
+ * @brief Returns the first active backend from self::$_usedBackends.
+ * @return null if no backend active, otherwise OCP\Authentication\IApacheBackend
+ */
+ private static function findFirstActiveUsedBackend() {
+ foreach (self::$_usedBackends as $backend) {
+ if ($backend instanceof OCP\Authentication\IApacheBackend) {
+ if ($backend->isSessionActive()) {
+ return $backend;
+ }
+ }
+ }
+
+ return null;
+ }
}