File tree Expand file tree Collapse file tree
apps/webhook_listeners/lib/Controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626use OCP \AppFramework \OCS \OCSForbiddenException ;
2727use OCP \AppFramework \OCS \OCSNotFoundException ;
2828use OCP \AppFramework \OCSController ;
29+ use OCP \IGroupManager ;
2930use OCP \IRequest ;
3031use OCP \ISession ;
32+ use OCP \IUserSession ;
3133use Psr \Log \LoggerInterface ;
3234
3335/**
@@ -42,6 +44,8 @@ public function __construct(
4244 private WebhookListenerMapper $ mapper ,
4345 private ?string $ userId ,
4446 private ISession $ session ,
47+ private IUserSession $ userSession ,
48+ private IGroupManager $ groupManager ,
4549 ) {
4650 parent ::__construct ($ appName , $ request );
4751 }
@@ -150,6 +154,12 @@ public function create(
150154 } catch (\ValueError $ e ) {
151155 throw new OCSBadRequestException ('This auth method does not exist ' );
152156 }
157+
158+ $ user = $ this ->userSession ->getUser ();
159+ if (!$ user || !$ this ->groupManager ->isAdmin ($ user ->getUID ())) {
160+ $ tokenNeeded = null ;
161+ }
162+
153163 try {
154164 $ webhookListener = $ this ->mapper ->addWebhookListener (
155165 $ appId ,
You can’t perform that action at this time.
0 commit comments