mirror of
https://github.com/nextcloud/passman.git
synced 2025-09-12 16:04:35 +08:00
Fix if statements
This commit is contained in:
parent
0de232ffab
commit
f30f986d60
8 changed files with 21 additions and 33 deletions
|
@ -59,7 +59,7 @@ class FileController extends ApiController {
|
||||||
return new JSONResponse($this->fileService->deleteFile($file_id, $this->userId));
|
return new JSONResponse($this->fileService->deleteFile($file_id, $this->userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateFile($file_id, $file_data, $filename, $mimetype, $size){
|
public function updateFile($file_id, $file_data, $filename){
|
||||||
try{
|
try{
|
||||||
$file = $this->fileService->getFile($file_id, $this->userId);
|
$file = $this->fileService->getFile($file_id, $this->userId);
|
||||||
} catch (\Exception $doesNotExistException){
|
} catch (\Exception $doesNotExistException){
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TranslationController extends ApiController {
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
*/
|
*/
|
||||||
public function getLanguageStrings($lang) {
|
public function getLanguageStrings() {
|
||||||
$translations = array(
|
$translations = array(
|
||||||
// js/app/controllers/bookmarklet.js
|
// js/app/controllers/bookmarklet.js
|
||||||
'generating.sharing.keys' => $this->trans->t('Generating sharing keys ( %step / 2)'),
|
'generating.sharing.keys' => $this->trans->t('Generating sharing keys ( %step / 2)'),
|
||||||
|
|
|
@ -149,6 +149,6 @@ class VaultController extends ApiController {
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
public function delete($vault_id) {
|
public function delete($vault_id) {
|
||||||
return;
|
return new JSONResponse($vault_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,13 +60,11 @@ class SharingACLMapper extends Mapper {
|
||||||
public function getItemACL($user_id, $item_guid) {
|
public function getItemACL($user_id, $item_guid) {
|
||||||
$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
|
$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
|
||||||
$filter = [$item_guid];
|
$filter = [$item_guid];
|
||||||
if ($user_id === null){
|
$q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? ';
|
||||||
$q .= 'user_id is null';
|
if ($user_id !== null){
|
||||||
}
|
|
||||||
else {
|
|
||||||
$q .= 'user_id = ? ';
|
|
||||||
$filter[] = $user_id;
|
$filter[] = $user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->findEntity($q, $filter);
|
return $this->findEntity($q, $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,8 @@ class CredentialService {
|
||||||
$acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
|
$acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
|
||||||
if ($acl->hasPermission(SharingACL::READ)) {
|
if ($acl->hasPermission(SharingACL::READ)) {
|
||||||
return $credential;
|
return $credential;
|
||||||
} else {
|
|
||||||
throw new DoesNotExistException("Did expect one result but found none when executing");
|
|
||||||
}
|
}
|
||||||
|
throw new DoesNotExistException("Did expect one result but found none when executing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,7 @@ class CronService {
|
||||||
'', array(),
|
'', array(),
|
||||||
$link, $credential->getUserId(), Activity::TYPE_ITEM_EXPIRED);
|
$link, $credential->getUserId(), Activity::TYPE_ITEM_EXPIRED);
|
||||||
$this->notificationService->credentialExpiredNotification($credential);
|
$this->notificationService->credentialExpiredNotification($credential);
|
||||||
} else {
|
|
||||||
$this->logger->debug($credential->getLabel() .' is expired, already notified!', array('app' => 'passman'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,7 +39,8 @@ class SettingsService {
|
||||||
'vault_key_strength',
|
'vault_key_strength',
|
||||||
'check_version',
|
'check_version',
|
||||||
'https_check',
|
'https_check',
|
||||||
'disable_contextmenu'
|
'disable_contextmenu',
|
||||||
|
'settings_loaded'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function __construct($UserId, IConfig $config, $AppName) {
|
public function __construct($UserId, IConfig $config, $AppName) {
|
||||||
|
@ -74,14 +75,11 @@ class SettingsService {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAppSetting($key, $default_value = null) {
|
public function getAppSetting($key, $default_value = null) {
|
||||||
if (isset($this->settings[$key])) {
|
$value = ($this->settings[$key]) ? $this->settings[$key] : $this->config->getAppValue('passman', $key, $default_value);
|
||||||
$value = $this->settings[$key];
|
|
||||||
if (in_array($key, $this->numeric_settings)) {
|
if (in_array($key, $this->numeric_settings)) {
|
||||||
$value = intval($value);
|
$value = intval($value);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$value = $this->config->getAppValue('passman', $key, $default_value);
|
|
||||||
}
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,19 +19,15 @@ class ShareMiddleware extends Middleware {
|
||||||
|
|
||||||
public function beforeController($controller, $methodName) {
|
public function beforeController($controller, $methodName) {
|
||||||
if ($controller instanceof ShareController) {
|
if ($controller instanceof ShareController) {
|
||||||
$http_response_code = \OCP\AppFramework\Http::STATUS_FORBIDDEN;
|
|
||||||
$result = 'FORBIDDEN';
|
|
||||||
|
|
||||||
if (in_array($methodName, array('updateSharedCredentialACL', 'getFile', 'getItemAcl'))) {
|
|
||||||
$sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled'));
|
|
||||||
} else {
|
|
||||||
$publicMethods = array('createPublicShare', 'getPublicCredentialData');
|
|
||||||
$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
|
|
||||||
$sharing_enabled = ($this->settings->isEnabled($setting));
|
|
||||||
if ($methodName === 'getVaultItems' || $methodName === 'getPendingRequests') {
|
|
||||||
$http_response_code = Http::STATUS_OK;
|
$http_response_code = Http::STATUS_OK;
|
||||||
$result = array();
|
$result = array();
|
||||||
}
|
$publicMethods = array('createPublicShare', 'getPublicCredentialData');
|
||||||
|
$user_pub_methods = array('updateSharedCredentialACL', 'getFile', 'getItemAcl');
|
||||||
|
$setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled';
|
||||||
|
$sharing_enabled = ($this->settings->isEnabled($setting));
|
||||||
|
|
||||||
|
if(in_array($methodName, $user_pub_methods)){
|
||||||
|
$sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue