mirror of
https://github.com/nextcloud/passman.git
synced 2025-11-12 07:01:35 +08:00
add option to disable the global search inclusion
This commit is contained in:
parent
5d95c9a6ea
commit
ca2717d610
4 changed files with 41 additions and 26 deletions
|
|
@ -94,6 +94,7 @@ $(document).ready(function () {
|
|||
$('#passman_https_check').prop('checked', (settings.getKey('https_check').toString().toLowerCase() === '1'));
|
||||
$('#passman_disable_contextmenu').prop('checked', (settings.getKey('disable_contextmenu').toString().toLowerCase() === '1'));
|
||||
$('#passman_disable_debugger').prop('checked', (settings.getKey('disable_debugger').toString().toLowerCase() === '1'));
|
||||
$('#passman_disable_global_search_inclusion').prop('checked', (settings.getKey('disable_global_search_inclusion').toString().toLowerCase() === '1'));
|
||||
$('#vault_key_strength').val(settings.getKey('vault_key_strength'));
|
||||
|
||||
|
||||
|
|
@ -113,6 +114,10 @@ $(document).ready(function () {
|
|||
settings.setAdminKey('disable_debugger', ($(this).is(":checked")) ? 1 : 0);
|
||||
});
|
||||
|
||||
$('#passman_disable_global_search_inclusion').change(function () {
|
||||
settings.setAdminKey('disable_global_search_inclusion', ($(this).is(":checked")) ? 1 : 0);
|
||||
});
|
||||
|
||||
$('#passman_sharing_enabled').change(function () {
|
||||
settings.setAdminKey('user_sharing_enabled', ($(this).is(":checked")) ? 1 : 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace OCA\Passman\Search;
|
|||
use OCA\Passman\AppInfo\Application;
|
||||
use OCA\Passman\Db\CredentialMapper;
|
||||
use OCA\Passman\Db\VaultMapper;
|
||||
use OCA\Passman\Service\SettingsService;
|
||||
use OCA\Passman\Service\VaultService;
|
||||
use OCA\Passman\Utility\Utils;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
|
@ -38,22 +39,19 @@ use OCP\Search\IProvider;
|
|||
use OCP\Search\ISearchQuery;
|
||||
use OCP\Search\SearchResult;
|
||||
use OCP\Search\SearchResultEntry;
|
||||
use Safe\Exceptions\StringsException;
|
||||
|
||||
class Provider implements IProvider {
|
||||
|
||||
/** @var IL10N */
|
||||
private IL10N $l10n;
|
||||
|
||||
/** @var IURLGenerator */
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
private IDBConnection $db;
|
||||
private SettingsService $settings;
|
||||
|
||||
public function __construct(IL10N $l10n, IURLGenerator $urlGenerator, IDBConnection $db) {
|
||||
public function __construct(IL10N $l10n, IURLGenerator $urlGenerator, IDBConnection $db, SettingsService $settings) {
|
||||
$this->l10n = $l10n;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->db = $db;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
|
|
@ -74,31 +72,33 @@ class Provider implements IProvider {
|
|||
}
|
||||
|
||||
public function search(IUser $user, ISearchQuery $query): SearchResult {
|
||||
$VaultService = new VaultService(new VaultMapper($this->db, new Utils()));
|
||||
$Vaults = $VaultService->getByUser($user->getUID());
|
||||
$CredentialMapper = new CredentialMapper($this->db, new Utils());
|
||||
|
||||
$searchResultEntries = [];
|
||||
|
||||
foreach ($Vaults as $Vault) {
|
||||
try {
|
||||
$Credentials = $CredentialMapper->getCredentialsByVaultId($Vault->getId(), $Vault->getUserId());
|
||||
if ($this->settings->getAppSetting('disable_global_search_inclusion', 1) === 0) {
|
||||
$VaultService = new VaultService(new VaultMapper($this->db, new Utils()));
|
||||
$Vaults = $VaultService->getByUser($user->getUID());
|
||||
$CredentialMapper = new CredentialMapper($this->db, new Utils());
|
||||
|
||||
foreach ($Credentials as $Credential) {
|
||||
if (strpos($Credential->getLabel(), $query->getTerm()) !== false) {
|
||||
try {
|
||||
$searchResultEntries[] = new SearchResultEntry(
|
||||
$this->urlGenerator->imagePath(Application::APP_ID, 'app.svg'),
|
||||
$Credential->getLabel(),
|
||||
\sprintf("Part of Passman vault %s", $Vault->getName()),
|
||||
$this->urlGenerator->linkToRoute('passman.page.index') . "#/vault/" . $Vault->getGuid() . "?show=" . $Credential->getGuid()
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
foreach ($Vaults as $Vault) {
|
||||
try {
|
||||
$Credentials = $CredentialMapper->getCredentialsByVaultId($Vault->getId(), $Vault->getUserId());
|
||||
|
||||
foreach ($Credentials as $Credential) {
|
||||
if (strpos($Credential->getLabel(), $query->getTerm()) !== false) {
|
||||
try {
|
||||
$searchResultEntries[] = new SearchResultEntry(
|
||||
$this->urlGenerator->imagePath(Application::APP_ID, 'app.svg'),
|
||||
$Credential->getLabel(),
|
||||
\sprintf("Part of Passman vault %s", $Vault->getName()),
|
||||
$this->urlGenerator->linkToRoute('passman.page.index') . "#/vault/" . $Vault->getGuid() . "?show=" . $Credential->getGuid()
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DoesNotExistException $e) {
|
||||
} catch (MultipleObjectsReturnedException $e) {
|
||||
}
|
||||
} catch (DoesNotExistException $e) {
|
||||
} catch (MultipleObjectsReturnedException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class SettingsService {
|
|||
'check_version',
|
||||
'https_check',
|
||||
'disable_contextmenu',
|
||||
'disable_global_search_inclusion',
|
||||
'settings_loaded'
|
||||
);
|
||||
|
||||
|
|
@ -57,6 +58,7 @@ class SettingsService {
|
|||
'server_side_encryption' => $this->config->getAppValue('passman', 'server_side_encryption', 'aes-256-cbc'),
|
||||
'rounds_pbkdf2_stretching' => $this->config->getAppValue('passman', 'rounds_pbkdf2_stretching', 100),
|
||||
'disable_debugger' => $this->config->getAppValue('passman', 'disable_debugger', 1),
|
||||
'disable_global_search_inclusion' => $this->config->getAppValue('passman', 'disable_global_search_inclusion', 1),
|
||||
'settings_loaded' => 1
|
||||
);
|
||||
}
|
||||
|
|
@ -118,4 +120,4 @@ class SettingsService {
|
|||
$value = intval($this->getAppSetting($setting, false));
|
||||
return ($value === 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,14 @@ $ciphers = openssl_get_cipher_methods();
|
|||
<?php p($l->t('Disable JavaScript debugger')); ?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="checkbox" name="passman_disable_global_search_inclusion"
|
||||
id="passman_disable_global_search_inclusion" class="checkbox"
|
||||
value="0"/>
|
||||
<label for="passman_disable_global_search_inclusion">
|
||||
<?php p($l->t('Disable global search inclusion')); ?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label for="vault_key_strength">Minimum vault key
|
||||
strength:</label>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue