Completed
Push — master ( 14cc8d...910687 )
by Joas
27:00 queued 24s
created
core/Controller/WebAuthnController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 			'preLoginNameUsedAsUserName',
78 78
 			['uid' => &$uid]
79 79
 		);
80
-		$this->logger->debug('Got UID: ' . $uid);
80
+		$this->logger->debug('Got UID: '.$uid);
81 81
 
82 82
 		$publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost());
83 83
 		$this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions));
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -25,69 +25,69 @@
 block discarded – undo
25 25
 use Webauthn\PublicKeyCredentialRequestOptions;
26 26
 
27 27
 class WebAuthnController extends Controller {
28
-	private const WEBAUTHN_LOGIN = 'webauthn_login';
29
-	private const WEBAUTHN_LOGIN_UID = 'webauthn_login_uid';
28
+    private const WEBAUTHN_LOGIN = 'webauthn_login';
29
+    private const WEBAUTHN_LOGIN_UID = 'webauthn_login_uid';
30 30
 
31
-	public function __construct(
32
-		string $appName,
33
-		IRequest $request,
34
-		private Manager $webAuthnManger,
35
-		private ISession $session,
36
-		private LoggerInterface $logger,
37
-		private WebAuthnChain $webAuthnChain,
38
-		private URLGenerator $urlGenerator,
39
-	) {
40
-		parent::__construct($appName, $request);
41
-	}
31
+    public function __construct(
32
+        string $appName,
33
+        IRequest $request,
34
+        private Manager $webAuthnManger,
35
+        private ISession $session,
36
+        private LoggerInterface $logger,
37
+        private WebAuthnChain $webAuthnChain,
38
+        private URLGenerator $urlGenerator,
39
+    ) {
40
+        parent::__construct($appName, $request);
41
+    }
42 42
 
43
-	#[PublicPage]
44
-	#[UseSession]
45
-	#[FrontpageRoute(verb: 'POST', url: 'login/webauthn/start')]
46
-	public function startAuthentication(string $loginName): JSONResponse {
47
-		$this->logger->debug('Starting WebAuthn login');
43
+    #[PublicPage]
44
+    #[UseSession]
45
+    #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/start')]
46
+    public function startAuthentication(string $loginName): JSONResponse {
47
+        $this->logger->debug('Starting WebAuthn login');
48 48
 
49
-		$this->logger->debug('Converting login name to UID');
50
-		$uid = $loginName;
51
-		Util::emitHook(
52
-			'\OCA\Files_Sharing\API\Server2Server',
53
-			'preLoginNameUsedAsUserName',
54
-			['uid' => &$uid]
55
-		);
56
-		$this->logger->debug('Got UID: ' . $uid);
49
+        $this->logger->debug('Converting login name to UID');
50
+        $uid = $loginName;
51
+        Util::emitHook(
52
+            '\OCA\Files_Sharing\API\Server2Server',
53
+            'preLoginNameUsedAsUserName',
54
+            ['uid' => &$uid]
55
+        );
56
+        $this->logger->debug('Got UID: ' . $uid);
57 57
 
58
-		$publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost());
59
-		$this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions));
60
-		$this->session->set(self::WEBAUTHN_LOGIN_UID, $uid);
58
+        $publicKeyCredentialRequestOptions = $this->webAuthnManger->startAuthentication($uid, $this->request->getServerHost());
59
+        $this->session->set(self::WEBAUTHN_LOGIN, json_encode($publicKeyCredentialRequestOptions));
60
+        $this->session->set(self::WEBAUTHN_LOGIN_UID, $uid);
61 61
 
62
-		return new JSONResponse($publicKeyCredentialRequestOptions);
63
-	}
62
+        return new JSONResponse($publicKeyCredentialRequestOptions);
63
+    }
64 64
 
65
-	#[PublicPage]
66
-	#[UseSession]
67
-	#[FrontpageRoute(verb: 'POST', url: 'login/webauthn/finish')]
68
-	public function finishAuthentication(string $data): JSONResponse {
69
-		$this->logger->debug('Validating WebAuthn login');
65
+    #[PublicPage]
66
+    #[UseSession]
67
+    #[FrontpageRoute(verb: 'POST', url: 'login/webauthn/finish')]
68
+    public function finishAuthentication(string $data): JSONResponse {
69
+        $this->logger->debug('Validating WebAuthn login');
70 70
 
71
-		if (!$this->session->exists(self::WEBAUTHN_LOGIN) || !$this->session->exists(self::WEBAUTHN_LOGIN_UID)) {
72
-			$this->logger->debug('Trying to finish WebAuthn login without session data');
73
-			return new JSONResponse([], Http::STATUS_BAD_REQUEST);
74
-		}
71
+        if (!$this->session->exists(self::WEBAUTHN_LOGIN) || !$this->session->exists(self::WEBAUTHN_LOGIN_UID)) {
72
+            $this->logger->debug('Trying to finish WebAuthn login without session data');
73
+            return new JSONResponse([], Http::STATUS_BAD_REQUEST);
74
+        }
75 75
 
76
-		// Obtain the publicKeyCredentialOptions from when we started the registration
77
-		$publicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions::createFromString($this->session->get(self::WEBAUTHN_LOGIN));
78
-		$uid = $this->session->get(self::WEBAUTHN_LOGIN_UID);
79
-		$this->webAuthnManger->finishAuthentication($publicKeyCredentialRequestOptions, $data, $uid);
76
+        // Obtain the publicKeyCredentialOptions from when we started the registration
77
+        $publicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions::createFromString($this->session->get(self::WEBAUTHN_LOGIN));
78
+        $uid = $this->session->get(self::WEBAUTHN_LOGIN_UID);
79
+        $this->webAuthnManger->finishAuthentication($publicKeyCredentialRequestOptions, $data, $uid);
80 80
 
81
-		//TODO: add other parameters
82
-		$loginData = new LoginData(
83
-			$this->request,
84
-			$uid,
85
-			''
86
-		);
87
-		$this->webAuthnChain->process($loginData);
81
+        //TODO: add other parameters
82
+        $loginData = new LoginData(
83
+            $this->request,
84
+            $uid,
85
+            ''
86
+        );
87
+        $this->webAuthnChain->process($loginData);
88 88
 
89
-		return new JSONResponse([
90
-			'defaultRedirectUrl' => $this->urlGenerator->linkToDefaultPageUrl(),
91
-		]);
92
-	}
89
+        return new JSONResponse([
90
+            'defaultRedirectUrl' => $this->urlGenerator->linkToDefaultPageUrl(),
91
+        ]);
92
+    }
93 93
 }
Please login to merge, or discard this patch.
core/templates/loginflowv2/authpicker.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	<h2><?php p($l->t('Connect to your account')) ?></h2>
31 31
 	<p class="info">
32 32
 		<?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [
33
-			'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
33
+			'<strong>'.\OCP\Util::sanitizeHTML($_['client']).'</strong>',
34 34
 			\OCP\Util::sanitizeHTML($_['instanceName'])
35 35
 		])) ?>
36 36
 	</p>
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
 	<h2><?php p($l->t('Connect to your account')) ?></h2>
32 32
 	<p class="info">
33 33
 		<?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [
34
-			'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
35
-			\OCP\Util::sanitizeHTML($_['instanceName'])
36
-		])) ?>
34
+            '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
35
+            \OCP\Util::sanitizeHTML($_['instanceName'])
36
+        ])) ?>
37 37
 	</p>
38 38
 
39 39
 	<div class="notecard warning">
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Sabre/TrashFolderFile.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 namespace OCA\Files_Trashbin\Sabre;
29 29
 
30 30
 class TrashFolderFile extends AbstractTrashFile {
31
-	public function get() {
32
-		return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb');
33
-	}
31
+    public function get() {
32
+        return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb');
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/INamedToken.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 namespace OC\Authentication\Token;
29 29
 
30 30
 interface INamedToken extends IToken {
31
-	/**
32
-	 * Set token name
33
-	 *
34
-	 * @param string $name
35
-	 * @return void
36
-	 */
37
-	public function setName(string $name): void;
31
+    /**
32
+     * Set token name
33
+     *
34
+     * @param string $name
35
+     * @return void
36
+     */
37
+    public function setName(string $name): void;
38 38
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 * @return boolean
144 144
 	 */
145 145
 	public function isActive(IUser $user): bool {
146
-		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
146
+		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function($appId) {
147 147
 			return $appId !== $this->appName;
148 148
 		});
149 149
 		foreach ($appIds as $appId) {
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -22,120 +22,120 @@
 block discarded – undo
22 22
 
23 23
 class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSettings {
24 24
 
25
-	/** @var AppManager */
26
-	private $appManager;
25
+    /** @var AppManager */
26
+    private $appManager;
27 27
 
28
-	/**
29
-	 * @param string $appName
30
-	 * @param BackupCodeStorage $storage
31
-	 * @param IL10N $l10n
32
-	 * @param AppManager $appManager
33
-	 */
34
-	public function __construct(
35
-		private string $appName,
36
-		private BackupCodeStorage $storage,
37
-		private IL10N $l10n,
38
-		AppManager $appManager,
39
-		private IInitialStateService $initialStateService,
40
-		private ITemplateManager $templateManager,
41
-	) {
42
-		$this->appManager = $appManager;
43
-	}
28
+    /**
29
+     * @param string $appName
30
+     * @param BackupCodeStorage $storage
31
+     * @param IL10N $l10n
32
+     * @param AppManager $appManager
33
+     */
34
+    public function __construct(
35
+        private string $appName,
36
+        private BackupCodeStorage $storage,
37
+        private IL10N $l10n,
38
+        AppManager $appManager,
39
+        private IInitialStateService $initialStateService,
40
+        private ITemplateManager $templateManager,
41
+    ) {
42
+        $this->appManager = $appManager;
43
+    }
44 44
 
45
-	/**
46
-	 * Get unique identifier of this 2FA provider
47
-	 *
48
-	 * @return string
49
-	 */
50
-	public function getId(): string {
51
-		return 'backup_codes';
52
-	}
45
+    /**
46
+     * Get unique identifier of this 2FA provider
47
+     *
48
+     * @return string
49
+     */
50
+    public function getId(): string {
51
+        return 'backup_codes';
52
+    }
53 53
 
54
-	/**
55
-	 * Get the display name for selecting the 2FA provider
56
-	 *
57
-	 * @return string
58
-	 */
59
-	public function getDisplayName(): string {
60
-		return $this->l10n->t('Backup code');
61
-	}
54
+    /**
55
+     * Get the display name for selecting the 2FA provider
56
+     *
57
+     * @return string
58
+     */
59
+    public function getDisplayName(): string {
60
+        return $this->l10n->t('Backup code');
61
+    }
62 62
 
63
-	/**
64
-	 * Get the description for selecting the 2FA provider
65
-	 *
66
-	 * @return string
67
-	 */
68
-	public function getDescription(): string {
69
-		return $this->l10n->t('Use backup code');
70
-	}
63
+    /**
64
+     * Get the description for selecting the 2FA provider
65
+     *
66
+     * @return string
67
+     */
68
+    public function getDescription(): string {
69
+        return $this->l10n->t('Use backup code');
70
+    }
71 71
 
72
-	/**
73
-	 * Get the template for rending the 2FA provider view
74
-	 *
75
-	 * @param IUser $user
76
-	 * @return ITemplate
77
-	 */
78
-	public function getTemplate(IUser $user): ITemplate {
79
-		return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge');
80
-	}
72
+    /**
73
+     * Get the template for rending the 2FA provider view
74
+     *
75
+     * @param IUser $user
76
+     * @return ITemplate
77
+     */
78
+    public function getTemplate(IUser $user): ITemplate {
79
+        return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge');
80
+    }
81 81
 
82
-	/**
83
-	 * Verify the given challenge
84
-	 *
85
-	 * @param IUser $user
86
-	 * @param string $challenge
87
-	 * @return bool
88
-	 */
89
-	public function verifyChallenge(IUser $user, string $challenge): bool {
90
-		return $this->storage->validateCode($user, $challenge);
91
-	}
82
+    /**
83
+     * Verify the given challenge
84
+     *
85
+     * @param IUser $user
86
+     * @param string $challenge
87
+     * @return bool
88
+     */
89
+    public function verifyChallenge(IUser $user, string $challenge): bool {
90
+        return $this->storage->validateCode($user, $challenge);
91
+    }
92 92
 
93
-	/**
94
-	 * Decides whether 2FA is enabled for the given user
95
-	 *
96
-	 * @param IUser $user
97
-	 * @return boolean
98
-	 */
99
-	public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
100
-		return $this->storage->hasBackupCodes($user);
101
-	}
93
+    /**
94
+     * Decides whether 2FA is enabled for the given user
95
+     *
96
+     * @param IUser $user
97
+     * @return boolean
98
+     */
99
+    public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
100
+        return $this->storage->hasBackupCodes($user);
101
+    }
102 102
 
103
-	/**
104
-	 * Determine whether backup codes should be active or not
105
-	 *
106
-	 * Backup codes only make sense if at least one 2FA provider is active,
107
-	 * hence this method checks all enabled apps on whether they provide 2FA
108
-	 * functionality or not. If there's at least one app, backup codes are
109
-	 * enabled on the personal settings page.
110
-	 *
111
-	 * @param IUser $user
112
-	 * @return boolean
113
-	 */
114
-	public function isActive(IUser $user): bool {
115
-		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
116
-			return $appId !== $this->appName;
117
-		});
118
-		foreach ($appIds as $appId) {
119
-			$info = $this->appManager->getAppInfo($appId);
120
-			if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) {
121
-				return true;
122
-			}
123
-		}
124
-		return false;
125
-	}
103
+    /**
104
+     * Determine whether backup codes should be active or not
105
+     *
106
+     * Backup codes only make sense if at least one 2FA provider is active,
107
+     * hence this method checks all enabled apps on whether they provide 2FA
108
+     * functionality or not. If there's at least one app, backup codes are
109
+     * enabled on the personal settings page.
110
+     *
111
+     * @param IUser $user
112
+     * @return boolean
113
+     */
114
+    public function isActive(IUser $user): bool {
115
+        $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
116
+            return $appId !== $this->appName;
117
+        });
118
+        foreach ($appIds as $appId) {
119
+            $info = $this->appManager->getAppInfo($appId);
120
+            if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) {
121
+                return true;
122
+            }
123
+        }
124
+        return false;
125
+    }
126 126
 
127
-	/**
128
-	 * @param IUser $user
129
-	 *
130
-	 * @return IPersonalProviderSettings
131
-	 */
132
-	public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
133
-		$state = $this->storage->getBackupCodesState($user);
134
-		$this->initialStateService->provideInitialState($this->appName, 'state', $state);
135
-		return new Personal();
136
-	}
127
+    /**
128
+     * @param IUser $user
129
+     *
130
+     * @return IPersonalProviderSettings
131
+     */
132
+    public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
133
+        $state = $this->storage->getBackupCodesState($user);
134
+        $this->initialStateService->provideInitialState($this->appName, 'state', $state);
135
+        return new Personal();
136
+    }
137 137
 
138
-	public function disableFor(IUser $user) {
139
-		$this->storage->deleteCodes($user);
140
-	}
138
+    public function disableFor(IUser $user) {
139
+        $this->storage->deleteCodes($user);
140
+    }
141 141
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Settings/ASettings.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	}
147 147
 
148 148
 	private function entitiesToArray(array $entities) {
149
-		return array_map(function (IEntity $entity) {
150
-			$events = array_map(function (IEntityEvent $entityEvent) {
149
+		return array_map(function(IEntity $entity) {
150
+			$events = array_map(function(IEntityEvent $entityEvent) {
151 151
 				return [
152 152
 					'eventName' => $entityEvent->getEventName(),
153 153
 					'displayName' => $entityEvent->getDisplayName()
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	}
165 165
 
166 166
 	private function operatorsToArray(array $operators) {
167
-		$operators = array_filter($operators, function (IOperation $operator) {
167
+		$operators = array_filter($operators, function(IOperation $operator) {
168 168
 			return $operator->isAvailableForScope($this->getScope());
169 169
 		});
170 170
 
171
-		return array_map(function (IOperation $operator) {
171
+		return array_map(function(IOperation $operator) {
172 172
 			return [
173 173
 				'id' => get_class($operator),
174 174
 				'icon' => $operator->getIcon(),
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	private function checksToArray(array $checks) {
185
-		$checks = array_filter($checks, function (ICheck $check) {
185
+		$checks = array_filter($checks, function(ICheck $check) {
186 186
 			return $check->isAvailableForScope($this->getScope());
187 187
 		});
188 188
 
189
-		return array_map(function (ICheck $check) {
189
+		return array_map(function(ICheck $check) {
190 190
 			return [
191 191
 				'id' => get_class($check),
192 192
 				'supportedEntities' => $check->supportedEntities(),
Please login to merge, or discard this patch.
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -26,130 +26,130 @@
 block discarded – undo
26 26
 use OCP\WorkflowEngine\ISpecificOperation;
27 27
 
28 28
 abstract class ASettings implements ISettings {
29
-	public function __construct(
30
-		private string $appName,
31
-		private IL10N $l10n,
32
-		private IEventDispatcher $eventDispatcher,
33
-		protected Manager $manager,
34
-		private IInitialState $initialStateService,
35
-		private IConfig $config,
36
-		private IURLGenerator $urlGenerator,
37
-	) {
38
-	}
39
-
40
-	abstract public function getScope(): int;
41
-
42
-	/**
43
-	 * @return TemplateResponse
44
-	 */
45
-	public function getForm(): TemplateResponse {
46
-		// @deprecated in 20.0.0: retire this one in favor of the typed event
47
-		$this->eventDispatcher->dispatch(
48
-			'OCP\WorkflowEngine::loadAdditionalSettingScripts',
49
-			new LoadSettingsScriptsEvent()
50
-		);
51
-		$this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent());
52
-
53
-		$entities = $this->manager->getEntitiesList();
54
-		$this->initialStateService->provideInitialState(
55
-			'entities',
56
-			$this->entitiesToArray($entities)
57
-		);
58
-
59
-		$operators = $this->manager->getOperatorList();
60
-		$this->initialStateService->provideInitialState(
61
-			'operators',
62
-			$this->operatorsToArray($operators)
63
-		);
64
-
65
-		$checks = $this->manager->getCheckList();
66
-		$this->initialStateService->provideInitialState(
67
-			'checks',
68
-			$this->checksToArray($checks)
69
-		);
70
-
71
-		$this->initialStateService->provideInitialState(
72
-			'scope',
73
-			$this->getScope()
74
-		);
75
-
76
-		$this->initialStateService->provideInitialState(
77
-			'appstoreenabled',
78
-			$this->config->getSystemValueBool('appstoreenabled', true)
79
-		);
80
-
81
-		$this->initialStateService->provideInitialState(
82
-			'doc-url',
83
-			$this->urlGenerator->linkToDocs('admin-workflowengine')
84
-		);
85
-
86
-		return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank');
87
-	}
88
-
89
-	/**
90
-	 * @return string the section ID, e.g. 'sharing'
91
-	 */
92
-	public function getSection(): ?string {
93
-		return 'workflow';
94
-	}
95
-
96
-	/**
97
-	 * @return int whether the form should be rather on the top or bottom of
98
-	 *             the admin section. The forms are arranged in ascending order of the
99
-	 *             priority values. It is required to return a value between 0 and 100.
100
-	 *
101
-	 * E.g.: 70
102
-	 */
103
-	public function getPriority(): int {
104
-		return 0;
105
-	}
106
-
107
-	private function entitiesToArray(array $entities) {
108
-		return array_map(function (IEntity $entity) {
109
-			$events = array_map(function (IEntityEvent $entityEvent) {
110
-				return [
111
-					'eventName' => $entityEvent->getEventName(),
112
-					'displayName' => $entityEvent->getDisplayName()
113
-				];
114
-			}, $entity->getEvents());
115
-
116
-			return [
117
-				'id' => get_class($entity),
118
-				'icon' => $entity->getIcon(),
119
-				'name' => $entity->getName(),
120
-				'events' => $events,
121
-			];
122
-		}, $entities);
123
-	}
124
-
125
-	private function operatorsToArray(array $operators) {
126
-		$operators = array_filter($operators, function (IOperation $operator) {
127
-			return $operator->isAvailableForScope($this->getScope());
128
-		});
129
-
130
-		return array_map(function (IOperation $operator) {
131
-			return [
132
-				'id' => get_class($operator),
133
-				'icon' => $operator->getIcon(),
134
-				'name' => $operator->getDisplayName(),
135
-				'description' => $operator->getDescription(),
136
-				'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '',
137
-				'isComplex' => $operator instanceof IComplexOperation,
138
-				'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '',
139
-			];
140
-		}, $operators);
141
-	}
142
-
143
-	private function checksToArray(array $checks) {
144
-		$checks = array_filter($checks, function (ICheck $check) {
145
-			return $check->isAvailableForScope($this->getScope());
146
-		});
147
-
148
-		return array_map(function (ICheck $check) {
149
-			return [
150
-				'id' => get_class($check),
151
-				'supportedEntities' => $check->supportedEntities(),
152
-			];
153
-		}, $checks);
154
-	}
29
+    public function __construct(
30
+        private string $appName,
31
+        private IL10N $l10n,
32
+        private IEventDispatcher $eventDispatcher,
33
+        protected Manager $manager,
34
+        private IInitialState $initialStateService,
35
+        private IConfig $config,
36
+        private IURLGenerator $urlGenerator,
37
+    ) {
38
+    }
39
+
40
+    abstract public function getScope(): int;
41
+
42
+    /**
43
+     * @return TemplateResponse
44
+     */
45
+    public function getForm(): TemplateResponse {
46
+        // @deprecated in 20.0.0: retire this one in favor of the typed event
47
+        $this->eventDispatcher->dispatch(
48
+            'OCP\WorkflowEngine::loadAdditionalSettingScripts',
49
+            new LoadSettingsScriptsEvent()
50
+        );
51
+        $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent());
52
+
53
+        $entities = $this->manager->getEntitiesList();
54
+        $this->initialStateService->provideInitialState(
55
+            'entities',
56
+            $this->entitiesToArray($entities)
57
+        );
58
+
59
+        $operators = $this->manager->getOperatorList();
60
+        $this->initialStateService->provideInitialState(
61
+            'operators',
62
+            $this->operatorsToArray($operators)
63
+        );
64
+
65
+        $checks = $this->manager->getCheckList();
66
+        $this->initialStateService->provideInitialState(
67
+            'checks',
68
+            $this->checksToArray($checks)
69
+        );
70
+
71
+        $this->initialStateService->provideInitialState(
72
+            'scope',
73
+            $this->getScope()
74
+        );
75
+
76
+        $this->initialStateService->provideInitialState(
77
+            'appstoreenabled',
78
+            $this->config->getSystemValueBool('appstoreenabled', true)
79
+        );
80
+
81
+        $this->initialStateService->provideInitialState(
82
+            'doc-url',
83
+            $this->urlGenerator->linkToDocs('admin-workflowengine')
84
+        );
85
+
86
+        return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank');
87
+    }
88
+
89
+    /**
90
+     * @return string the section ID, e.g. 'sharing'
91
+     */
92
+    public function getSection(): ?string {
93
+        return 'workflow';
94
+    }
95
+
96
+    /**
97
+     * @return int whether the form should be rather on the top or bottom of
98
+     *             the admin section. The forms are arranged in ascending order of the
99
+     *             priority values. It is required to return a value between 0 and 100.
100
+     *
101
+     * E.g.: 70
102
+     */
103
+    public function getPriority(): int {
104
+        return 0;
105
+    }
106
+
107
+    private function entitiesToArray(array $entities) {
108
+        return array_map(function (IEntity $entity) {
109
+            $events = array_map(function (IEntityEvent $entityEvent) {
110
+                return [
111
+                    'eventName' => $entityEvent->getEventName(),
112
+                    'displayName' => $entityEvent->getDisplayName()
113
+                ];
114
+            }, $entity->getEvents());
115
+
116
+            return [
117
+                'id' => get_class($entity),
118
+                'icon' => $entity->getIcon(),
119
+                'name' => $entity->getName(),
120
+                'events' => $events,
121
+            ];
122
+        }, $entities);
123
+    }
124
+
125
+    private function operatorsToArray(array $operators) {
126
+        $operators = array_filter($operators, function (IOperation $operator) {
127
+            return $operator->isAvailableForScope($this->getScope());
128
+        });
129
+
130
+        return array_map(function (IOperation $operator) {
131
+            return [
132
+                'id' => get_class($operator),
133
+                'icon' => $operator->getIcon(),
134
+                'name' => $operator->getDisplayName(),
135
+                'description' => $operator->getDescription(),
136
+                'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '',
137
+                'isComplex' => $operator instanceof IComplexOperation,
138
+                'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '',
139
+            ];
140
+        }, $operators);
141
+    }
142
+
143
+    private function checksToArray(array $checks) {
144
+        $checks = array_filter($checks, function (ICheck $check) {
145
+            return $check->isAvailableForScope($this->getScope());
146
+        });
147
+
148
+        return array_map(function (ICheck $check) {
149
+            return [
150
+                'id' => get_class($check),
151
+                'supportedEntities' => $check->supportedEntities(),
152
+            ];
153
+        }, $checks);
154
+    }
155 155
 }
Please login to merge, or discard this patch.
lib/private/Authentication/TwoFactorAuth/ProviderSet.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 	 * @return IProvider[]
73 73
 	 */
74 74
 	public function getPrimaryProviders(): array {
75
-		return array_filter($this->providers, function (IProvider $provider) {
75
+		return array_filter($this->providers, function(IProvider $provider) {
76 76
 			return !($provider instanceof BackupCodesProvider);
77 77
 		});
78 78
 	}
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,49 +33,49 @@
 block discarded – undo
33 33
  * Contains all two-factor provider information for the two-factor login challenge
34 34
  */
35 35
 class ProviderSet {
36
-	/** @var IProvider */
37
-	private $providers;
36
+    /** @var IProvider */
37
+    private $providers;
38 38
 
39
-	/** @var bool */
40
-	private $providerMissing;
39
+    /** @var bool */
40
+    private $providerMissing;
41 41
 
42
-	/**
43
-	 * @param IProvider[] $providers
44
-	 * @param bool $providerMissing
45
-	 */
46
-	public function __construct(array $providers, bool $providerMissing) {
47
-		$this->providers = [];
48
-		foreach ($providers as $provider) {
49
-			$this->providers[$provider->getId()] = $provider;
50
-		}
51
-		$this->providerMissing = $providerMissing;
52
-	}
42
+    /**
43
+     * @param IProvider[] $providers
44
+     * @param bool $providerMissing
45
+     */
46
+    public function __construct(array $providers, bool $providerMissing) {
47
+        $this->providers = [];
48
+        foreach ($providers as $provider) {
49
+            $this->providers[$provider->getId()] = $provider;
50
+        }
51
+        $this->providerMissing = $providerMissing;
52
+    }
53 53
 
54
-	/**
55
-	 * @param string $providerId
56
-	 * @return IProvider|null
57
-	 */
58
-	public function getProvider(string $providerId) {
59
-		return $this->providers[$providerId] ?? null;
60
-	}
54
+    /**
55
+     * @param string $providerId
56
+     * @return IProvider|null
57
+     */
58
+    public function getProvider(string $providerId) {
59
+        return $this->providers[$providerId] ?? null;
60
+    }
61 61
 
62
-	/**
63
-	 * @return IProvider[]
64
-	 */
65
-	public function getProviders(): array {
66
-		return $this->providers;
67
-	}
62
+    /**
63
+     * @return IProvider[]
64
+     */
65
+    public function getProviders(): array {
66
+        return $this->providers;
67
+    }
68 68
 
69
-	/**
70
-	 * @return IProvider[]
71
-	 */
72
-	public function getPrimaryProviders(): array {
73
-		return array_filter($this->providers, function (IProvider $provider) {
74
-			return !($provider instanceof BackupCodesProvider);
75
-		});
76
-	}
69
+    /**
70
+     * @return IProvider[]
71
+     */
72
+    public function getPrimaryProviders(): array {
73
+        return array_filter($this->providers, function (IProvider $provider) {
74
+            return !($provider instanceof BackupCodesProvider);
75
+        });
76
+    }
77 77
 
78
-	public function isProviderMissing(): bool {
79
-		return $this->providerMissing;
80
-	}
78
+    public function isProviderMissing(): bool {
79
+        return $this->providerMissing;
80
+    }
81 81
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Resources/Collection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @since 16.0.0
127 127
 	 */
128 128
 	public function addResource(IResource $resource): void {
129
-		array_map(function (IResource $r) use ($resource) {
129
+		array_map(function(IResource $r) use ($resource) {
130 130
 			if ($this->isSameResource($r, $resource)) {
131 131
 				throw new ResourceException('Already part of the collection');
132 132
 			}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @since 16.0.0
159 159
 	 */
160 160
 	public function removeResource(IResource $resource): void {
161
-		$this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
161
+		$this->resources = array_filter($this->getResources(), function(IResource $r) use ($resource) {
162 162
 			return !$this->isSameResource($r, $resource);
163 163
 		});
164 164
 
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -18,163 +18,163 @@
 block discarded – undo
18 18
 use OCP\IUser;
19 19
 
20 20
 class Collection implements ICollection {
21
-	/** @var IResource[] */
22
-	protected array $resources = [];
23
-
24
-	public function __construct(
25
-		/** @var Manager $manager */
26
-		protected IManager $manager,
27
-		protected IDBConnection $connection,
28
-		protected int $id,
29
-		protected string $name,
30
-		protected ?IUser $userForAccess = null,
31
-		protected ?bool $access = null,
32
-	) {
33
-	}
34
-
35
-	/**
36
-	 * @since 16.0.0
37
-	 */
38
-	public function getId(): int {
39
-		return $this->id;
40
-	}
41
-
42
-	/**
43
-	 * @since 16.0.0
44
-	 */
45
-	public function getName(): string {
46
-		return $this->name;
47
-	}
48
-
49
-	/**
50
-	 * @since 16.0.0
51
-	 */
52
-	public function setName(string $name): void {
53
-		$query = $this->connection->getQueryBuilder();
54
-		$query->update(Manager::TABLE_COLLECTIONS)
55
-			->set('name', $query->createNamedParameter($name))
56
-			->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
57
-		$query->executeStatement();
58
-
59
-		$this->name = $name;
60
-	}
61
-
62
-	/**
63
-	 * @return IResource[]
64
-	 * @since 16.0.0
65
-	 */
66
-	public function getResources(): array {
67
-		if (empty($this->resources)) {
68
-			$this->resources = $this->manager->getResourcesByCollectionForUser($this, $this->userForAccess);
69
-		}
70
-
71
-		return $this->resources;
72
-	}
73
-
74
-	/**
75
-	 * Adds a resource to a collection
76
-	 *
77
-	 * @throws ResourceException when the resource is already part of the collection
78
-	 * @since 16.0.0
79
-	 */
80
-	public function addResource(IResource $resource): void {
81
-		array_map(function (IResource $r) use ($resource) {
82
-			if ($this->isSameResource($r, $resource)) {
83
-				throw new ResourceException('Already part of the collection');
84
-			}
85
-		}, $this->getResources());
86
-
87
-		$this->resources[] = $resource;
88
-
89
-		$query = $this->connection->getQueryBuilder();
90
-		$query->insert(Manager::TABLE_RESOURCES)
91
-			->values([
92
-				'collection_id' => $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT),
93
-				'resource_type' => $query->createNamedParameter($resource->getType()),
94
-				'resource_id' => $query->createNamedParameter($resource->getId()),
95
-			]);
96
-
97
-		try {
98
-			$query->execute();
99
-		} catch (ConstraintViolationException $e) {
100
-			throw new ResourceException('Already part of the collection');
101
-		}
102
-
103
-		$this->manager->invalidateAccessCacheForCollection($this);
104
-	}
105
-
106
-	/**
107
-	 * Removes a resource from a collection
108
-	 *
109
-	 * @since 16.0.0
110
-	 */
111
-	public function removeResource(IResource $resource): void {
112
-		$this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
113
-			return !$this->isSameResource($r, $resource);
114
-		});
115
-
116
-		$query = $this->connection->getQueryBuilder();
117
-		$query->delete(Manager::TABLE_RESOURCES)
118
-			->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)))
119
-			->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType())))
120
-			->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())));
121
-		$query->executeStatement();
122
-
123
-		if (empty($this->resources)) {
124
-			$this->removeCollection();
125
-		} else {
126
-			$this->manager->invalidateAccessCacheForCollection($this);
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * Can a user/guest access the collection
132
-	 *
133
-	 * @since 16.0.0
134
-	 */
135
-	public function canAccess(?IUser $user): bool {
136
-		if ($user instanceof IUser) {
137
-			return $this->canUserAccess($user);
138
-		}
139
-		return $this->canGuestAccess();
140
-	}
141
-
142
-	protected function canUserAccess(IUser $user): bool {
143
-		if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
144
-			return $this->access;
145
-		}
146
-
147
-		$access = $this->manager->canAccessCollection($this, $user);
148
-		if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
149
-			$this->access = $access;
150
-		}
151
-		return $access;
152
-	}
153
-
154
-	protected function canGuestAccess(): bool {
155
-		if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
156
-			return $this->access;
157
-		}
158
-
159
-		$access = $this->manager->canAccessCollection($this, null);
160
-		if (!$this->userForAccess instanceof IUser) {
161
-			$this->access = $access;
162
-		}
163
-		return $access;
164
-	}
165
-
166
-	protected function isSameResource(IResource $resource1, IResource $resource2): bool {
167
-		return $resource1->getType() === $resource2->getType() &&
168
-			$resource1->getId() === $resource2->getId();
169
-	}
170
-
171
-	protected function removeCollection(): void {
172
-		$query = $this->connection->getQueryBuilder();
173
-		$query->delete(Manager::TABLE_COLLECTIONS)
174
-			->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)));
175
-		$query->executeStatement();
176
-
177
-		$this->manager->invalidateAccessCacheForCollection($this);
178
-		$this->id = 0;
179
-	}
21
+    /** @var IResource[] */
22
+    protected array $resources = [];
23
+
24
+    public function __construct(
25
+        /** @var Manager $manager */
26
+        protected IManager $manager,
27
+        protected IDBConnection $connection,
28
+        protected int $id,
29
+        protected string $name,
30
+        protected ?IUser $userForAccess = null,
31
+        protected ?bool $access = null,
32
+    ) {
33
+    }
34
+
35
+    /**
36
+     * @since 16.0.0
37
+     */
38
+    public function getId(): int {
39
+        return $this->id;
40
+    }
41
+
42
+    /**
43
+     * @since 16.0.0
44
+     */
45
+    public function getName(): string {
46
+        return $this->name;
47
+    }
48
+
49
+    /**
50
+     * @since 16.0.0
51
+     */
52
+    public function setName(string $name): void {
53
+        $query = $this->connection->getQueryBuilder();
54
+        $query->update(Manager::TABLE_COLLECTIONS)
55
+            ->set('name', $query->createNamedParameter($name))
56
+            ->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
57
+        $query->executeStatement();
58
+
59
+        $this->name = $name;
60
+    }
61
+
62
+    /**
63
+     * @return IResource[]
64
+     * @since 16.0.0
65
+     */
66
+    public function getResources(): array {
67
+        if (empty($this->resources)) {
68
+            $this->resources = $this->manager->getResourcesByCollectionForUser($this, $this->userForAccess);
69
+        }
70
+
71
+        return $this->resources;
72
+    }
73
+
74
+    /**
75
+     * Adds a resource to a collection
76
+     *
77
+     * @throws ResourceException when the resource is already part of the collection
78
+     * @since 16.0.0
79
+     */
80
+    public function addResource(IResource $resource): void {
81
+        array_map(function (IResource $r) use ($resource) {
82
+            if ($this->isSameResource($r, $resource)) {
83
+                throw new ResourceException('Already part of the collection');
84
+            }
85
+        }, $this->getResources());
86
+
87
+        $this->resources[] = $resource;
88
+
89
+        $query = $this->connection->getQueryBuilder();
90
+        $query->insert(Manager::TABLE_RESOURCES)
91
+            ->values([
92
+                'collection_id' => $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT),
93
+                'resource_type' => $query->createNamedParameter($resource->getType()),
94
+                'resource_id' => $query->createNamedParameter($resource->getId()),
95
+            ]);
96
+
97
+        try {
98
+            $query->execute();
99
+        } catch (ConstraintViolationException $e) {
100
+            throw new ResourceException('Already part of the collection');
101
+        }
102
+
103
+        $this->manager->invalidateAccessCacheForCollection($this);
104
+    }
105
+
106
+    /**
107
+     * Removes a resource from a collection
108
+     *
109
+     * @since 16.0.0
110
+     */
111
+    public function removeResource(IResource $resource): void {
112
+        $this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
113
+            return !$this->isSameResource($r, $resource);
114
+        });
115
+
116
+        $query = $this->connection->getQueryBuilder();
117
+        $query->delete(Manager::TABLE_RESOURCES)
118
+            ->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)))
119
+            ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType())))
120
+            ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())));
121
+        $query->executeStatement();
122
+
123
+        if (empty($this->resources)) {
124
+            $this->removeCollection();
125
+        } else {
126
+            $this->manager->invalidateAccessCacheForCollection($this);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * Can a user/guest access the collection
132
+     *
133
+     * @since 16.0.0
134
+     */
135
+    public function canAccess(?IUser $user): bool {
136
+        if ($user instanceof IUser) {
137
+            return $this->canUserAccess($user);
138
+        }
139
+        return $this->canGuestAccess();
140
+    }
141
+
142
+    protected function canUserAccess(IUser $user): bool {
143
+        if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
144
+            return $this->access;
145
+        }
146
+
147
+        $access = $this->manager->canAccessCollection($this, $user);
148
+        if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
149
+            $this->access = $access;
150
+        }
151
+        return $access;
152
+    }
153
+
154
+    protected function canGuestAccess(): bool {
155
+        if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
156
+            return $this->access;
157
+        }
158
+
159
+        $access = $this->manager->canAccessCollection($this, null);
160
+        if (!$this->userForAccess instanceof IUser) {
161
+            $this->access = $access;
162
+        }
163
+        return $access;
164
+    }
165
+
166
+    protected function isSameResource(IResource $resource1, IResource $resource2): bool {
167
+        return $resource1->getType() === $resource2->getType() &&
168
+            $resource1->getId() === $resource2->getId();
169
+    }
170
+
171
+    protected function removeCollection(): void {
172
+        $query = $this->connection->getQueryBuilder();
173
+        $query->delete(Manager::TABLE_COLLECTIONS)
174
+            ->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)));
175
+        $query->executeStatement();
176
+
177
+        $this->manager->invalidateAccessCacheForCollection($this);
178
+        $this->id = 0;
179
+    }
180 180
 }
Please login to merge, or discard this patch.
lib/public/Accounts/PropertyDoesNotExistException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	 * @since 15.0.0
39 39
 	 */
40 40
 	public function __construct($property) {
41
-		parent::__construct('Property ' . $property . ' does not exist.');
41
+		parent::__construct('Property '.$property.' does not exist.');
42 42
 	}
43 43
 
44 44
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
  *
31 31
  */
32 32
 class PropertyDoesNotExistException extends \Exception {
33
-	/**
34
-	 * Constructor
35
-	 * @param string $msg the error message
36
-	 * @since 15.0.0
37
-	 */
38
-	public function __construct($property) {
39
-		parent::__construct('Property ' . $property . ' does not exist.');
40
-	}
33
+    /**
34
+     * Constructor
35
+     * @param string $msg the error message
36
+     * @since 15.0.0
37
+     */
38
+    public function __construct($property) {
39
+        parent::__construct('Property ' . $property . ' does not exist.');
40
+    }
41 41
 }
Please login to merge, or discard this patch.