diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 040b7eb..0000000 --- a/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-FileCopyrightText: Pondersource -# SPDX-License-Identifier: AGPL-3.0-or-later -#/js/* binary diff --git a/js/plugin.js b/js/plugin.js index 8b13678..1025b98 100644 --- a/js/plugin.js +++ b/js/plugin.js @@ -6,7 +6,8 @@ var mfazoneFileListPlugin = { // if (fileList.id === 'trashbin' || fileList.id === 'files.public') { // return; // } - + console.log("Attaching MFA Zone plugin to " + fileList.id); + console.log(fileList); fileList.registerTabView(new OCA.mfazones.MfaZoneTabView()); fileList.fileActions.registerAction({ diff --git a/js/tabview.js b/js/tabview.js index ebcfa6c..4ae8cc9 100644 --- a/js/tabview.js +++ b/js/tabview.js @@ -1,6 +1,88 @@ // SPDX-FileCopyrightText: Pondersource // SPDX-License-Identifier: AGPL-3.0-or-later (function () { + function renderHTML(enabled) { + return ` +
+ + + + + +
+
+
+
+

+ +
+
+ `; + } const MfaZoneTabView = OCA.Files.DetailTabView.extend({ id: 'mfazoneTabView', className: 'tab mfazoneTabView', @@ -16,166 +98,12 @@ console.error("File info not found!"); return; } - const $html = ` -
- - - - - -
-
-
-
-

- -
-
- `; - const $htmlDisabled = ` -
- - - - - -
-
-
-
-

- -
-
- `; + console.log("Rendering MFA Zone tab for " + fileInfo.getFullPath()); + // if (!fileInfo.isDirectory()) { + // this.$el.html(`
MFA Zones are currently disabled for files.
`); + // console.log("Not a directory, MFA zone detail tab disabled."); + // return; + // } const accessUrl = OC.generateUrl('/apps/mfazones/access'), data = { source: fileInfo.getFullPath() @@ -190,11 +118,7 @@ async: true, success: function (response) { console.log(response); - if (response.access === false) { - _self.addHtml(_self, $htmlDisabled, data, false); - } else { - _self.addHtml(_self, $html, data, true); - } + _self.addHtml(_self, data, response.access); }, error: function (xhr, ajaxOptions, thrownError) { console.log(xhr.status); @@ -202,8 +126,8 @@ }, }); }, - addHtml: function (context, html, data, enabled) { - context.$el.html(html); + addHtml: function (context, data, enabled) { + context.$el.html(renderHTML(enabled)); const statusUrl = OC.generateUrl('/apps/mfazones/get'); $.ajax({ type: 'GET', diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index e159a73..c4ea394 100755 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -44,23 +44,23 @@ public function __construct() { $server = $container->getServer(); $eventDispatcher = $this->getContainer()->get(IEventDispatcher::class); - $eventDispatcher->addListener( - BeforeUserLoggedInEvent::class, - function ($event) { - // Check if the user has MFA verified - $twoFactorManager = \OC::$server->get(TwoFactorManager::class); - $userManager = \OC::$server->get(IUserManager::class); - $user = $userManager->get($event->getUsername()); - $hasMfaEnabled = $twoFactorManager->isTwoFactorAuthenticated($user); - // Redirect users to enable MFA if not already enabled and have 2FA provider - if (!$hasMfaEnabled) { - $providerSet = $twoFactorManager->getProviderSet($user); - if(!empty($loginProviders) && !$providerSet->isProviderMissing()){ - $twoFactorManager->prepareTwoFactorLogin($user, false); - } - } - } - ); + // $eventDispatcher->addListener( + // BeforeUserLoggedInEvent::class, + // function ($event) { + // // Check if the user has MFA verified + // $twoFactorManager = \OC::$server->get(TwoFactorManager::class); + // $userManager = \OC::$server->get(IUserManager::class); + // $user = $userManager->get($event->getUsername()); + // $hasMfaEnabled = $twoFactorManager->isTwoFactorAuthenticated($user); + // // Redirect users to enable MFA if not already enabled and have 2FA provider + // if (!$hasMfaEnabled) { + // $providerSet = $twoFactorManager->getProviderSet($user); + // if(!empty($loginProviders) && !$providerSet->isProviderMissing()){ + // $twoFactorManager->prepareTwoFactorLogin($user, false); + // } + // } + // } + // ); $this->systemTagManager = $this->getContainer()->get(ISystemTagManager::class); $this->manager = $this->getContainer()->get(Manager::class); diff --git a/lib/Controller/MfazonesController.php b/lib/Controller/MfazonesController.php index 82de922..7ece5cb 100755 --- a/lib/Controller/MfazonesController.php +++ b/lib/Controller/MfazonesController.php @@ -212,6 +212,9 @@ public function set($source, $protect) } $userRoot = $this->rootFolder->getUserFolder($this->userId); $node = $userRoot->get($source); + if ($node->getType() !== 'dir') { + return new DataResponse(['not a directory'], Http::STATUS_FORBIDDEN); + } $tags = $this->systemTagManager->getAllTags( null, Application::TAG_NAME diff --git a/release/mfazones/lib/Controller/MfazonesController.php b/release/mfazones/lib/Controller/MfazonesController.php index 11bcbfd..86819f3 100644 --- a/release/mfazones/lib/Controller/MfazonesController.php +++ b/release/mfazones/lib/Controller/MfazonesController.php @@ -140,7 +140,7 @@ public function set($source, $protect) $type = $this->castObjectType($node->getType()); - if ($protect == "true") { + if ($protect === "true") { $this->tagMapper->assignTags($node->getId(), $type, $tagId); } else { $this->tagMapper->unassignTags($node->getId(), $type, $tagId); @@ -169,10 +169,10 @@ public function access($source) private function castObjectType($type) { - if ($type == 'file') { + if ($type === 'file') { return "files"; } - if ($type == "dir") { + if ($type === "dir") { return "files"; } return $type;