4444use OCP \ILogger ;
4545use OCP \IRequest ;
4646use OCP \ISession ;
47+ use OCP \IUserSession ;
4748use OCP \Security \ISecureRandom ;
4849use OCP \Session \Exceptions \SessionNotAvailableException ;
4950
@@ -55,6 +56,9 @@ class AuthSettingsController extends Controller {
5556 /** @var ISession */
5657 private $ session ;
5758
59+ /** IUserSession */
60+ private $ userSession ;
61+
5862 /** @var string */
5963 private $ uid ;
6064
@@ -77,6 +81,7 @@ class AuthSettingsController extends Controller {
7781 * @param ISession $session
7882 * @param ISecureRandom $random
7983 * @param string|null $userId
84+ * @param IUserSession $userSession
8085 * @param IManager $activityManager
8186 * @param RemoteWipe $remoteWipe
8287 * @param ILogger $logger
@@ -87,12 +92,14 @@ public function __construct(string $appName,
8792 ISession $ session ,
8893 ISecureRandom $ random ,
8994 ?string $ userId ,
95+ IUserSession $ userSession ,
9096 IManager $ activityManager ,
9197 RemoteWipe $ remoteWipe ,
9298 ILogger $ logger ) {
9399 parent ::__construct ($ appName , $ request );
94100 $ this ->tokenProvider = $ tokenProvider ;
95101 $ this ->uid = $ userId ;
102+ $ this ->userSession = $ userSession ;
96103 $ this ->session = $ session ;
97104 $ this ->random = $ random ;
98105 $ this ->activityManager = $ activityManager ;
@@ -114,6 +121,10 @@ public function create($name) {
114121 } catch (SessionNotAvailableException $ ex ) {
115122 return $ this ->getServiceNotAvailableResponse ();
116123 }
124+ if ($ this ->userSession ->getImpersonatingUserID () !== null )
125+ {
126+ return $ this ->getServiceNotAvailableResponse ();
127+ }
117128
118129 try {
119130 $ sessionToken = $ this ->tokenProvider ->getToken ($ sessionId );
0 commit comments