fix(encryption): Add the script to test encryption status only on logged in pages
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>pull/56424/head
parent
07b041f526
commit
7d1c7a5d24
@ -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