Passed
Push — master ( b96898...147073 )
by John
12:01 queued 12s
created
lib/private/legacy/user.php 1 patch
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -60,354 +60,354 @@
 block discarded – undo
60 60
  */
61 61
 class OC_User {
62 62
 
63
-	private static $_usedBackends = array();
64
-
65
-	private static $_setupedBackends = array();
66
-
67
-	// bool, stores if a user want to access a resource anonymously, e.g if they open a public link
68
-	private static $incognitoMode = false;
69
-
70
-	/**
71
-	 * Adds the backend to the list of used backends
72
-	 *
73
-	 * @param string|\OCP\UserInterface $backend default: database The backend to use for user management
74
-	 * @return bool
75
-	 *
76
-	 * Set the User Authentication Module
77
-	 * @suppress PhanDeprecatedFunction
78
-	 */
79
-	public static function useBackend($backend = 'database') {
80
-		if ($backend instanceof \OCP\UserInterface) {
81
-			self::$_usedBackends[get_class($backend)] = $backend;
82
-			\OC::$server->getUserManager()->registerBackend($backend);
83
-		} else {
84
-			// You'll never know what happens
85
-			if (null === $backend OR !is_string($backend)) {
86
-				$backend = 'database';
87
-			}
88
-
89
-			// Load backend
90
-			switch ($backend) {
91
-				case 'database':
92
-				case 'mysql':
93
-				case 'sqlite':
94
-					\OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG);
95
-					self::$_usedBackends[$backend] = new \OC\User\Database();
96
-					\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
97
-					break;
98
-				case 'dummy':
99
-					self::$_usedBackends[$backend] = new \Test\Util\User\Dummy();
100
-					\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
101
-					break;
102
-				default:
103
-					\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG);
104
-					$className = 'OC_USER_' . strtoupper($backend);
105
-					self::$_usedBackends[$backend] = new $className();
106
-					\OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
107
-					break;
108
-			}
109
-		}
110
-		return true;
111
-	}
112
-
113
-	/**
114
-	 * remove all used backends
115
-	 */
116
-	public static function clearBackends() {
117
-		self::$_usedBackends = array();
118
-		\OC::$server->getUserManager()->clearBackends();
119
-	}
120
-
121
-	/**
122
-	 * setup the configured backends in config.php
123
-	 * @suppress PhanDeprecatedFunction
124
-	 */
125
-	public static function setupBackends() {
126
-		OC_App::loadApps(['prelogin']);
127
-		$backends = \OC::$server->getSystemConfig()->getValue('user_backends', []);
128
-		if (isset($backends['default']) && !$backends['default']) {
129
-			// clear default backends
130
-			self::clearBackends();
131
-		}
132
-		foreach ($backends as $i => $config) {
133
-			if (!is_array($config)) {
134
-				continue;
135
-			}
136
-			$class = $config['class'];
137
-			$arguments = $config['arguments'];
138
-			if (class_exists($class)) {
139
-				if (array_search($i, self::$_setupedBackends) === false) {
140
-					// make a reflection object
141
-					$reflectionObj = new ReflectionClass($class);
142
-
143
-					// use Reflection to create a new instance, using the $args
144
-					$backend = $reflectionObj->newInstanceArgs($arguments);
145
-					self::useBackend($backend);
146
-					self::$_setupedBackends[] = $i;
147
-				} else {
148
-					\OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG);
149
-				}
150
-			} else {
151
-				\OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR);
152
-			}
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Try to login a user, assuming authentication
158
-	 * has already happened (e.g. via Single Sign On).
159
-	 *
160
-	 * Log in a user and regenerate a new session.
161
-	 *
162
-	 * @param \OCP\Authentication\IApacheBackend $backend
163
-	 * @return bool
164
-	 */
165
-	public static function loginWithApache(\OCP\Authentication\IApacheBackend $backend) {
166
-
167
-		$uid = $backend->getCurrentUserId();
168
-		$run = true;
169
-		OC_Hook::emit("OC_User", "pre_login", array("run" => &$run, "uid" => $uid, 'backend' => $backend));
170
-
171
-		if ($uid) {
172
-			if (self::getUser() !== $uid) {
173
-				self::setUserId($uid);
174
-				$userSession = \OC::$server->getUserSession();
175
-				$userSession->setLoginName($uid);
176
-				$request = OC::$server->getRequest();
177
-				$userSession->createSessionToken($request, $uid, $uid);
178
-				// setup the filesystem
179
-				OC_Util::setupFS($uid);
180
-				// first call the post_login hooks, the login-process needs to be
181
-				// completed before we can safely create the users folder.
182
-				// For example encryption needs to initialize the users keys first
183
-				// before we can create the user folder with the skeleton files
184
-				OC_Hook::emit(
185
-					'OC_User',
186
-					'post_login',
187
-					[
188
-						'uid' => $uid,
189
-						'password' => '',
190
-						'isTokenLogin' => false,
191
-					]
192
-				);
193
-				//trigger creation of user home and /files folder
194
-				\OC::$server->getUserFolder($uid);
195
-			}
196
-			return true;
197
-		}
198
-		return false;
199
-	}
200
-
201
-	/**
202
-	 * Verify with Apache whether user is authenticated.
203
-	 *
204
-	 * @return boolean|null
205
-	 *          true: authenticated
206
-	 *          false: not authenticated
207
-	 *          null: not handled / no backend available
208
-	 */
209
-	public static function handleApacheAuth() {
210
-		$backend = self::findFirstActiveUsedBackend();
211
-		if ($backend) {
212
-			OC_App::loadApps();
213
-
214
-			//setup extra user backends
215
-			self::setupBackends();
216
-			\OC::$server->getUserSession()->unsetMagicInCookie();
217
-
218
-			return self::loginWithApache($backend);
219
-		}
220
-
221
-		return null;
222
-	}
223
-
224
-
225
-	/**
226
-	 * Sets user id for session and triggers emit
227
-	 *
228
-	 * @param string $uid
229
-	 */
230
-	public static function setUserId($uid) {
231
-		$userSession = \OC::$server->getUserSession();
232
-		$userManager = \OC::$server->getUserManager();
233
-		if ($user = $userManager->get($uid)) {
234
-			$userSession->setUser($user);
235
-		} else {
236
-			\OC::$server->getSession()->set('user_id', $uid);
237
-		}
238
-	}
239
-
240
-	/**
241
-	 * Check if the user is logged in, considers also the HTTP basic credentials
242
-	 *
243
-	 * @deprecated use \OC::$server->getUserSession()->isLoggedIn()
244
-	 * @return bool
245
-	 */
246
-	public static function isLoggedIn() {
247
-		return \OC::$server->getUserSession()->isLoggedIn();
248
-	}
249
-
250
-	/**
251
-	 * set incognito mode, e.g. if a user wants to open a public link
252
-	 *
253
-	 * @param bool $status
254
-	 */
255
-	public static function setIncognitoMode($status) {
256
-		self::$incognitoMode = $status;
257
-	}
258
-
259
-	/**
260
-	 * get incognito mode status
261
-	 *
262
-	 * @return bool
263
-	 */
264
-	public static function isIncognitoMode() {
265
-		return self::$incognitoMode;
266
-	}
267
-
268
-	/**
269
-	 * Returns the current logout URL valid for the currently logged-in user
270
-	 *
271
-	 * @param \OCP\IURLGenerator $urlGenerator
272
-	 * @return string
273
-	 */
274
-	public static function getLogoutUrl(\OCP\IURLGenerator $urlGenerator) {
275
-		$backend = self::findFirstActiveUsedBackend();
276
-		if ($backend) {
277
-			return $backend->getLogoutUrl();
278
-		}
279
-
280
-		$logoutUrl = $urlGenerator->linkToRoute('core.login.logout');
281
-		$logoutUrl .= '?requesttoken=' . urlencode(\OCP\Util::callRegister());
282
-
283
-		return $logoutUrl;
284
-	}
285
-
286
-	/**
287
-	 * Check if the user is an admin user
288
-	 *
289
-	 * @param string $uid uid of the admin
290
-	 * @return bool
291
-	 */
292
-	public static function isAdminUser($uid) {
293
-		$group = \OC::$server->getGroupManager()->get('admin');
294
-		$user = \OC::$server->getUserManager()->get($uid);
295
-		if ($group && $user && $group->inGroup($user) && self::$incognitoMode === false) {
296
-			return true;
297
-		}
298
-		return false;
299
-	}
300
-
301
-
302
-	/**
303
-	 * get the user id of the user currently logged in.
304
-	 *
305
-	 * @return string|bool uid or false
306
-	 */
307
-	public static function getUser() {
308
-		$uid = \OC::$server->getSession() ? \OC::$server->getSession()->get('user_id') : null;
309
-		if (!is_null($uid) && self::$incognitoMode === false) {
310
-			return $uid;
311
-		} else {
312
-			return false;
313
-		}
314
-	}
315
-
316
-	/**
317
-	 * get the display name of the user currently logged in.
318
-	 *
319
-	 * @param string $uid
320
-	 * @return string|bool uid or false
321
-	 * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
322
-	 *                   get() of \OCP\IUserManager - \OC::$server->getUserManager()
323
-	 */
324
-	public static function getDisplayName($uid = null) {
325
-		if ($uid) {
326
-			$user = \OC::$server->getUserManager()->get($uid);
327
-			if ($user) {
328
-				return $user->getDisplayName();
329
-			} else {
330
-				return $uid;
331
-			}
332
-		} else {
333
-			$user = \OC::$server->getUserSession()->getUser();
334
-			if ($user) {
335
-				return $user->getDisplayName();
336
-			} else {
337
-				return false;
338
-			}
339
-		}
340
-	}
341
-
342
-	/**
343
-	 * Set password
344
-	 *
345
-	 * @param string $uid The username
346
-	 * @param string $password The new password
347
-	 * @param string $recoveryPassword for the encryption app to reset encryption keys
348
-	 * @return bool
349
-	 *
350
-	 * Change the password of a user
351
-	 */
352
-	public static function setPassword($uid, $password, $recoveryPassword = null) {
353
-		$user = \OC::$server->getUserManager()->get($uid);
354
-		if ($user) {
355
-			return $user->setPassword($password, $recoveryPassword);
356
-		} else {
357
-			return false;
358
-		}
359
-	}
360
-
361
-	/**
362
-	 * @param string $uid The username
363
-	 * @return string
364
-	 *
365
-	 * returns the path to the users home directory
366
-	 * @deprecated Use \OC::$server->getUserManager->getHome()
367
-	 */
368
-	public static function getHome($uid) {
369
-		$user = \OC::$server->getUserManager()->get($uid);
370
-		if ($user) {
371
-			return $user->getHome();
372
-		} else {
373
-			return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid;
374
-		}
375
-	}
376
-
377
-	/**
378
-	 * Get a list of all users display name
379
-	 *
380
-	 * @param string $search
381
-	 * @param int $limit
382
-	 * @param int $offset
383
-	 * @return array associative array with all display names (value) and corresponding uids (key)
384
-	 *
385
-	 * Get a list of all display names and user ids.
386
-	 * @deprecated Use \OC::$server->getUserManager->searchDisplayName($search, $limit, $offset) instead.
387
-	 */
388
-	public static function getDisplayNames($search = '', $limit = null, $offset = null) {
389
-		$displayNames = array();
390
-		$users = \OC::$server->getUserManager()->searchDisplayName($search, $limit, $offset);
391
-		foreach ($users as $user) {
392
-			$displayNames[$user->getUID()] = $user->getDisplayName();
393
-		}
394
-		return $displayNames;
395
-	}
396
-
397
-	/**
398
-	 * Returns the first active backend from self::$_usedBackends.
399
-	 *
400
-	 * @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend
401
-	 */
402
-	private static function findFirstActiveUsedBackend() {
403
-		foreach (self::$_usedBackends as $backend) {
404
-			if ($backend instanceof OCP\Authentication\IApacheBackend) {
405
-				if ($backend->isSessionActive()) {
406
-					return $backend;
407
-				}
408
-			}
409
-		}
410
-
411
-		return null;
412
-	}
63
+    private static $_usedBackends = array();
64
+
65
+    private static $_setupedBackends = array();
66
+
67
+    // bool, stores if a user want to access a resource anonymously, e.g if they open a public link
68
+    private static $incognitoMode = false;
69
+
70
+    /**
71
+     * Adds the backend to the list of used backends
72
+     *
73
+     * @param string|\OCP\UserInterface $backend default: database The backend to use for user management
74
+     * @return bool
75
+     *
76
+     * Set the User Authentication Module
77
+     * @suppress PhanDeprecatedFunction
78
+     */
79
+    public static function useBackend($backend = 'database') {
80
+        if ($backend instanceof \OCP\UserInterface) {
81
+            self::$_usedBackends[get_class($backend)] = $backend;
82
+            \OC::$server->getUserManager()->registerBackend($backend);
83
+        } else {
84
+            // You'll never know what happens
85
+            if (null === $backend OR !is_string($backend)) {
86
+                $backend = 'database';
87
+            }
88
+
89
+            // Load backend
90
+            switch ($backend) {
91
+                case 'database':
92
+                case 'mysql':
93
+                case 'sqlite':
94
+                    \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG);
95
+                    self::$_usedBackends[$backend] = new \OC\User\Database();
96
+                    \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
97
+                    break;
98
+                case 'dummy':
99
+                    self::$_usedBackends[$backend] = new \Test\Util\User\Dummy();
100
+                    \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
101
+                    break;
102
+                default:
103
+                    \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG);
104
+                    $className = 'OC_USER_' . strtoupper($backend);
105
+                    self::$_usedBackends[$backend] = new $className();
106
+                    \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]);
107
+                    break;
108
+            }
109
+        }
110
+        return true;
111
+    }
112
+
113
+    /**
114
+     * remove all used backends
115
+     */
116
+    public static function clearBackends() {
117
+        self::$_usedBackends = array();
118
+        \OC::$server->getUserManager()->clearBackends();
119
+    }
120
+
121
+    /**
122
+     * setup the configured backends in config.php
123
+     * @suppress PhanDeprecatedFunction
124
+     */
125
+    public static function setupBackends() {
126
+        OC_App::loadApps(['prelogin']);
127
+        $backends = \OC::$server->getSystemConfig()->getValue('user_backends', []);
128
+        if (isset($backends['default']) && !$backends['default']) {
129
+            // clear default backends
130
+            self::clearBackends();
131
+        }
132
+        foreach ($backends as $i => $config) {
133
+            if (!is_array($config)) {
134
+                continue;
135
+            }
136
+            $class = $config['class'];
137
+            $arguments = $config['arguments'];
138
+            if (class_exists($class)) {
139
+                if (array_search($i, self::$_setupedBackends) === false) {
140
+                    // make a reflection object
141
+                    $reflectionObj = new ReflectionClass($class);
142
+
143
+                    // use Reflection to create a new instance, using the $args
144
+                    $backend = $reflectionObj->newInstanceArgs($arguments);
145
+                    self::useBackend($backend);
146
+                    self::$_setupedBackends[] = $i;
147
+                } else {
148
+                    \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG);
149
+                }
150
+            } else {
151
+                \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR);
152
+            }
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Try to login a user, assuming authentication
158
+     * has already happened (e.g. via Single Sign On).
159
+     *
160
+     * Log in a user and regenerate a new session.
161
+     *
162
+     * @param \OCP\Authentication\IApacheBackend $backend
163
+     * @return bool
164
+     */
165
+    public static function loginWithApache(\OCP\Authentication\IApacheBackend $backend) {
166
+
167
+        $uid = $backend->getCurrentUserId();
168
+        $run = true;
169
+        OC_Hook::emit("OC_User", "pre_login", array("run" => &$run, "uid" => $uid, 'backend' => $backend));
170
+
171
+        if ($uid) {
172
+            if (self::getUser() !== $uid) {
173
+                self::setUserId($uid);
174
+                $userSession = \OC::$server->getUserSession();
175
+                $userSession->setLoginName($uid);
176
+                $request = OC::$server->getRequest();
177
+                $userSession->createSessionToken($request, $uid, $uid);
178
+                // setup the filesystem
179
+                OC_Util::setupFS($uid);
180
+                // first call the post_login hooks, the login-process needs to be
181
+                // completed before we can safely create the users folder.
182
+                // For example encryption needs to initialize the users keys first
183
+                // before we can create the user folder with the skeleton files
184
+                OC_Hook::emit(
185
+                    'OC_User',
186
+                    'post_login',
187
+                    [
188
+                        'uid' => $uid,
189
+                        'password' => '',
190
+                        'isTokenLogin' => false,
191
+                    ]
192
+                );
193
+                //trigger creation of user home and /files folder
194
+                \OC::$server->getUserFolder($uid);
195
+            }
196
+            return true;
197
+        }
198
+        return false;
199
+    }
200
+
201
+    /**
202
+     * Verify with Apache whether user is authenticated.
203
+     *
204
+     * @return boolean|null
205
+     *          true: authenticated
206
+     *          false: not authenticated
207
+     *          null: not handled / no backend available
208
+     */
209
+    public static function handleApacheAuth() {
210
+        $backend = self::findFirstActiveUsedBackend();
211
+        if ($backend) {
212
+            OC_App::loadApps();
213
+
214
+            //setup extra user backends
215
+            self::setupBackends();
216
+            \OC::$server->getUserSession()->unsetMagicInCookie();
217
+
218
+            return self::loginWithApache($backend);
219
+        }
220
+
221
+        return null;
222
+    }
223
+
224
+
225
+    /**
226
+     * Sets user id for session and triggers emit
227
+     *
228
+     * @param string $uid
229
+     */
230
+    public static function setUserId($uid) {
231
+        $userSession = \OC::$server->getUserSession();
232
+        $userManager = \OC::$server->getUserManager();
233
+        if ($user = $userManager->get($uid)) {
234
+            $userSession->setUser($user);
235
+        } else {
236
+            \OC::$server->getSession()->set('user_id', $uid);
237
+        }
238
+    }
239
+
240
+    /**
241
+     * Check if the user is logged in, considers also the HTTP basic credentials
242
+     *
243
+     * @deprecated use \OC::$server->getUserSession()->isLoggedIn()
244
+     * @return bool
245
+     */
246
+    public static function isLoggedIn() {
247
+        return \OC::$server->getUserSession()->isLoggedIn();
248
+    }
249
+
250
+    /**
251
+     * set incognito mode, e.g. if a user wants to open a public link
252
+     *
253
+     * @param bool $status
254
+     */
255
+    public static function setIncognitoMode($status) {
256
+        self::$incognitoMode = $status;
257
+    }
258
+
259
+    /**
260
+     * get incognito mode status
261
+     *
262
+     * @return bool
263
+     */
264
+    public static function isIncognitoMode() {
265
+        return self::$incognitoMode;
266
+    }
267
+
268
+    /**
269
+     * Returns the current logout URL valid for the currently logged-in user
270
+     *
271
+     * @param \OCP\IURLGenerator $urlGenerator
272
+     * @return string
273
+     */
274
+    public static function getLogoutUrl(\OCP\IURLGenerator $urlGenerator) {
275
+        $backend = self::findFirstActiveUsedBackend();
276
+        if ($backend) {
277
+            return $backend->getLogoutUrl();
278
+        }
279
+
280
+        $logoutUrl = $urlGenerator->linkToRoute('core.login.logout');
281
+        $logoutUrl .= '?requesttoken=' . urlencode(\OCP\Util::callRegister());
282
+
283
+        return $logoutUrl;
284
+    }
285
+
286
+    /**
287
+     * Check if the user is an admin user
288
+     *
289
+     * @param string $uid uid of the admin
290
+     * @return bool
291
+     */
292
+    public static function isAdminUser($uid) {
293
+        $group = \OC::$server->getGroupManager()->get('admin');
294
+        $user = \OC::$server->getUserManager()->get($uid);
295
+        if ($group && $user && $group->inGroup($user) && self::$incognitoMode === false) {
296
+            return true;
297
+        }
298
+        return false;
299
+    }
300
+
301
+
302
+    /**
303
+     * get the user id of the user currently logged in.
304
+     *
305
+     * @return string|bool uid or false
306
+     */
307
+    public static function getUser() {
308
+        $uid = \OC::$server->getSession() ? \OC::$server->getSession()->get('user_id') : null;
309
+        if (!is_null($uid) && self::$incognitoMode === false) {
310
+            return $uid;
311
+        } else {
312
+            return false;
313
+        }
314
+    }
315
+
316
+    /**
317
+     * get the display name of the user currently logged in.
318
+     *
319
+     * @param string $uid
320
+     * @return string|bool uid or false
321
+     * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method
322
+     *                   get() of \OCP\IUserManager - \OC::$server->getUserManager()
323
+     */
324
+    public static function getDisplayName($uid = null) {
325
+        if ($uid) {
326
+            $user = \OC::$server->getUserManager()->get($uid);
327
+            if ($user) {
328
+                return $user->getDisplayName();
329
+            } else {
330
+                return $uid;
331
+            }
332
+        } else {
333
+            $user = \OC::$server->getUserSession()->getUser();
334
+            if ($user) {
335
+                return $user->getDisplayName();
336
+            } else {
337
+                return false;
338
+            }
339
+        }
340
+    }
341
+
342
+    /**
343
+     * Set password
344
+     *
345
+     * @param string $uid The username
346
+     * @param string $password The new password
347
+     * @param string $recoveryPassword for the encryption app to reset encryption keys
348
+     * @return bool
349
+     *
350
+     * Change the password of a user
351
+     */
352
+    public static function setPassword($uid, $password, $recoveryPassword = null) {
353
+        $user = \OC::$server->getUserManager()->get($uid);
354
+        if ($user) {
355
+            return $user->setPassword($password, $recoveryPassword);
356
+        } else {
357
+            return false;
358
+        }
359
+    }
360
+
361
+    /**
362
+     * @param string $uid The username
363
+     * @return string
364
+     *
365
+     * returns the path to the users home directory
366
+     * @deprecated Use \OC::$server->getUserManager->getHome()
367
+     */
368
+    public static function getHome($uid) {
369
+        $user = \OC::$server->getUserManager()->get($uid);
370
+        if ($user) {
371
+            return $user->getHome();
372
+        } else {
373
+            return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid;
374
+        }
375
+    }
376
+
377
+    /**
378
+     * Get a list of all users display name
379
+     *
380
+     * @param string $search
381
+     * @param int $limit
382
+     * @param int $offset
383
+     * @return array associative array with all display names (value) and corresponding uids (key)
384
+     *
385
+     * Get a list of all display names and user ids.
386
+     * @deprecated Use \OC::$server->getUserManager->searchDisplayName($search, $limit, $offset) instead.
387
+     */
388
+    public static function getDisplayNames($search = '', $limit = null, $offset = null) {
389
+        $displayNames = array();
390
+        $users = \OC::$server->getUserManager()->searchDisplayName($search, $limit, $offset);
391
+        foreach ($users as $user) {
392
+            $displayNames[$user->getUID()] = $user->getDisplayName();
393
+        }
394
+        return $displayNames;
395
+    }
396
+
397
+    /**
398
+     * Returns the first active backend from self::$_usedBackends.
399
+     *
400
+     * @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend
401
+     */
402
+    private static function findFirstActiveUsedBackend() {
403
+        foreach (self::$_usedBackends as $backend) {
404
+            if ($backend instanceof OCP\Authentication\IApacheBackend) {
405
+                if ($backend->isSessionActive()) {
406
+                    return $backend;
407
+                }
408
+            }
409
+        }
410
+
411
+        return null;
412
+    }
413 413
 }
Please login to merge, or discard this patch.