aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/User
diff options
context:
space:
mode:
authorGreta Doci <gretadoci@gmail.com>2019-06-12 14:26:01 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2019-09-15 12:04:27 +0200
commit0a874c51af8dd6652c694f0545489af23d53771a (patch)
tree6781c94e2bb54cf4392ae826abf08086ff277321 /lib/private/User
parentd231fc9843b117c3361ce0b4e030d55c59607005 (diff)
downloadnextcloud-server-0a874c51af8dd6652c694f0545489af23d53771a.tar.gz
nextcloud-server-0a874c51af8dd6652c694f0545489af23d53771a.zip
Disable app token creation for impersonated people, ref #15539
Signed-off-by: Greta Doci <gretadoci@gmail.com>
Diffstat (limited to 'lib/private/User')
-rw-r--r--lib/private/User/Session.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php
index 13519d97ef4..ba909c81053 100644
--- a/lib/private/User/Session.php
+++ b/lib/private/User/Session.php
@@ -315,6 +315,29 @@ class Session implements IUserSession, Emitter {
}
/**
+ * @return mixed
+ */
+ public function getImpersonatingUserID(): ?string {
+
+ return $this->session->get('oldUserId');
+
+ }
+
+ public function setImpersonatingUserID(bool $useCurrentUser = true): void {
+ if ($useCurrentUser === false) {
+ $this->session->remove('oldUserId');
+ return;
+ }
+
+ $currentUser = $this->getUser();
+
+ if ($currentUser === null) {
+ throw new \OC\User\NoUserException();
+ }
+ $this->session->set('oldUserId', $currentUser->getUID());
+
+ }
+ /**
* set the token id
*
* @param int|null $token that was used to log in