aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/User/LazyUser.php17
-rw-r--r--lib/private/User/User.php5
-rw-r--r--lib/public/IUser.php8
3 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php
index 396d3c252f1..ae10937a66b 100644
--- a/lib/private/User/LazyUser.php
+++ b/lib/private/User/LazyUser.php
@@ -51,6 +51,11 @@ class LazyUser implements IUser {
$this->user = $this->userManager->get($this->uid);
}
}
+
+ if ($this->user === null) {
+ throw new \Exception('User not found');
+ }
+
/** @var IUser */
$user = $this->user;
return $user;
@@ -167,4 +172,16 @@ class LazyUser implements IUser {
public function setManagerUids(array $uids): void {
$this->getUser()->setManagerUids($uids);
}
+
+ public function isFederated(): bool {
+ try {
+ // If getUser succeeds then user is definitely not federated
+ // This could fail for other reasons (especially a race condition where a user is deleted)
+ // But it's what we have now
+ $this->getUser();
+ return false;
+ } catch (\Exception $e) {
+ return true;
+ }
+ }
}
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index daa78011007..398ea9e1a19 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -619,4 +619,9 @@ class User implements IUser {
$this->emitter->emit('\OC\User', 'changeUser', [$this, $feature, $value, $oldValue]);
}
}
+
+ public function isFederated(): bool {
+ // Federated users only use LazyUser
+ return 0;
+ }
}
diff --git a/lib/public/IUser.php b/lib/public/IUser.php
index b326e6192c0..61ecb5d2f21 100644
--- a/lib/public/IUser.php
+++ b/lib/public/IUser.php
@@ -287,4 +287,12 @@ interface IUser {
* @since 27.0.0
*/
public function setManagerUids(array $uids): void;
+
+ /**
+ * Check if the user is federated (from another server)
+ *
+ * @return boll
+ * @since 28.0.11
+ */
+ public function isFederated(): bool;
}