Merge pull request #56422 from nextcloud/backport/56189/stable31
[stable31] fix(encryption): Add the script to test encryption status only on logged in pagespull/56511/head
commit
c2d06d3306
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Encryption\Listeners;
|
||||
|
||||
use OCA\Encryption\AppInfo\Application;
|
||||
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Util;
|
||||
|
||||
/** @template-implements IEventListener<BeforeTemplateRenderedEvent> */
|
||||
class BeforeTemplateRenderedListener implements IEventListener {
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof BeforeTemplateRenderedEvent)) {
|
||||
// Unrelated
|
||||
return;
|
||||
}
|
||||
|
||||
if ($event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) {
|
||||
// Do not test encryption status on public or login pages
|
||||
return;
|
||||
}
|
||||
|
||||
Util::addScript(Application::APP_ID, 'encryption');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue