From 0a874c51af8dd6652c694f0545489af23d53771a Mon Sep 17 00:00:00 2001 From: Greta Doci Date: Wed, 12 Jun 2019 14:26:01 +0200 Subject: Disable app token creation for impersonated people, ref #15539 Signed-off-by: Greta Doci --- lib/private/User/Session.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/private') 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 @@ -314,6 +314,29 @@ class Session implements IUserSession, Emitter { return null; } + /** + * @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 * -- cgit v1.2.3