Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
resolve review threads
  • Loading branch information
mrvahedi68 committed Jan 4, 2023
commit 16fc4bb23d5f6fb1cef7a1db52ae5c6cd7e53292
57 changes: 2 additions & 55 deletions apps/workflowengine/lib/Check/MfaVerified.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
class MfaVerified implements ICheck, IFileCheck {
use TFileCheck;

/** @var array */
/** @psalm-suppress PropertyNotSetInConstructor */
/** @psalm-suppress MissingPropertyType */
protected $fileIds;

/** @var IL10N */
protected $l;

Expand All @@ -66,9 +61,9 @@ public function __construct(IL10N $l, ISession $session) {
public function executeCheck($operator, $value): bool {
$mfaVerified = $this->session->get('user_saml.samlUserData')["mfa_verified"][0];
if (strtolower($value) == 'true') {
return $mfaVerified == '1'; //Mfa verified must not have access
return $mfaVerified == '1'; // checking whether the current user is MFA-verified
} else {
return $mfaVerified != '1';
return $mfaVerified != '1'; // checking whether the current user is not MFA-verified
}
}

Expand All @@ -87,54 +82,6 @@ public function validateCheck($operator, $value): void {
}
}

/**
* Get the file ids of the given path and its parents
* @param ICache $cache
* @param string $path
* @param bool $isExternalStorage
* @return int[]
*/
protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
/** @psalm-suppress InvalidArgument */
if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) {
// Special implementation for groupfolder since all groupfolders share the same storage
// id so add the group folder id in the cache key too.
$groupFolderStorage = $this->storage;
if ($this->storage instanceof Wrapper) {
$groupFolderStorage = $this->storage->getInstanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class);
}
if ($groupFolderStorage === null) {
throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.');
}
/**
* @psalm-suppress UndefinedDocblockClass
* @psalm-suppress UndefinedInterfaceMethod
*/
$cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId();
} else {
$cacheId = $cache->getNumericStorageId();
}
if (isset($this->fileIds[$cacheId][$path])) {
return $this->fileIds[$cacheId][$path];
}

$parentIds = [];
if ($path !== $this->dirname($path)) {
$parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage);
} elseif (!$isExternalStorage) {
return [];
}

$fileId = $cache->getId($path);
if ($fileId !== -1) {
$parentIds[] = $fileId;
}

$this->fileIds[$cacheId][$path] = $parentIds;

return $parentIds;
}

/**
* @param string $path
* @return string
Expand Down
2 changes: 1 addition & 1 deletion apps/workflowengine/src/components/Checks/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const FileChecks = [

{
class: 'OCA\\WorkflowEngine\\Check\\MfaVerified',
name: t('workflowengine', 'Mfa Verified'),
name: t('workflowengine', 'MFA Verified'),
operators: [
{ operator: 'is', name: t('workflowengine', 'is verified?') },
],
Expand Down