-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(files_sharing): add public name prompt for files requests
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
- Loading branch information
Showing
12 changed files
with
299 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/files_sharing/lib/Listener/LoadPublicFileRequestAuthListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
namespace OCA\Files_Sharing\Listener; | ||
|
||
use OCA\Files_Sharing\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 LoadPublicFileRequestAuthListener implements IEventListener { | ||
public function handle(Event $event): void { | ||
if (!$event instanceof BeforeTemplateRenderedEvent) { | ||
return; | ||
} | ||
|
||
// Make sure we are on a public page rendering | ||
if ($event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_PUBLIC) { | ||
return; | ||
} | ||
Util::addScript(Application::APP_ID, Application::APP_ID . '-public'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { spawnDialog } from '@nextcloud/dialogs' | ||
import { defineAsyncComponent } from 'vue' | ||
import logger from './services/logger' | ||
|
||
const nick = localStorage.getItem('nick') | ||
const publicAuthPromptShown = localStorage.getItem('publicAuthPromptShown') | ||
|
||
// If we don't have a nickname or the public auth prompt hasn't been shown yet, show it | ||
// We still show the prompt if the user has a nickname to double check | ||
if (!nick || !publicAuthPromptShown) { | ||
spawnDialog( | ||
defineAsyncComponent(() => import('./views/PublicAuthPrompt.vue')), | ||
{}, | ||
() => localStorage.setItem('publicAuthPromptShown', 'true'), | ||
) | ||
} else { | ||
logger.debug(`Public auth prompt already shown. Current nickname is '${nick}'`) | ||
} |
Oops, something went wrong.