Passed
Push — master ( a54144...fce1dd )
by Morris
12:27 queued 11s
created
apps/user_ldap/lib/LogWrapper.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
  * @brief wraps around static Nextcloud core methods
29 29
  */
30 30
 class LogWrapper {
31
-	protected $app = 'user_ldap';
31
+    protected $app = 'user_ldap';
32 32
 
33
-	/**
34
-	 * @brief states whether the filesystem was loaded
35
-	 * @return bool
36
-	 */
37
-	public function log($msg, $level) {
38
-		\OCP\Util::writeLog($this->app, $msg, $level);
39
-	}
33
+    /**
34
+     * @brief states whether the filesystem was loaded
35
+     * @return bool
36
+     */
37
+    public function log($msg, $level) {
38
+        \OCP\Util::writeLog($this->app, $msg, $level);
39
+    }
40 40
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/FilesystemHelper.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@
 block discarded – undo
29 29
  */
30 30
 class FilesystemHelper {
31 31
 
32
-	/**
33
-	 * @brief states whether the filesystem was loaded
34
-	 * @return bool
35
-	 */
36
-	public function isLoaded() {
37
-		return \OC\Files\Filesystem::$loaded;
38
-	}
32
+    /**
33
+     * @brief states whether the filesystem was loaded
34
+     * @return bool
35
+     */
36
+    public function isLoaded() {
37
+        return \OC\Files\Filesystem::$loaded;
38
+    }
39 39
 
40
-	/**
41
-	 * @brief initializes the filesystem for the given user
42
-	 * @param string $uid the Nextcloud username of the user
43
-	 */
44
-	public function setup($uid) {
45
-		\OC_Util::setupFS($uid);
46
-	}
40
+    /**
41
+     * @brief initializes the filesystem for the given user
42
+     * @param string $uid the Nextcloud username of the user
43
+     */
44
+    public function setup($uid) {
45
+        \OC_Util::setupFS($uid);
46
+    }
47 47
 }
Please login to merge, or discard this patch.
apps/federation/lib/Controller/SettingsController.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -34,91 +34,91 @@
 block discarded – undo
34 34
 
35 35
 class SettingsController extends Controller {
36 36
 
37
-	/** @var IL10N */
38
-	private $l;
39
-
40
-	/** @var  TrustedServers */
41
-	private $trustedServers;
42
-
43
-	/**
44
-	 * @param string $AppName
45
-	 * @param IRequest $request
46
-	 * @param IL10N $l10n
47
-	 * @param TrustedServers $trustedServers
48
-	 */
49
-	public function __construct($AppName,
50
-								IRequest $request,
51
-								IL10N $l10n,
52
-								TrustedServers $trustedServers
53
-	) {
54
-		parent::__construct($AppName, $request);
55
-		$this->l = $l10n;
56
-		$this->trustedServers = $trustedServers;
57
-	}
58
-
59
-
60
-	/**
61
-	 * add server to the list of trusted Nextclouds
62
-	 *
63
-	 * @param string $url
64
-	 * @return DataResponse
65
-	 * @throws HintException
66
-	 */
67
-	public function addServer($url) {
68
-		$this->checkServer($url);
69
-		$id = $this->trustedServers->addServer($url);
70
-
71
-		return new DataResponse(
72
-			[
73
-				'url' => $url,
74
-				'id' => $id,
75
-				'message' => (string) $this->l->t('Added to the list of trusted servers')
76
-			]
77
-		);
78
-	}
79
-
80
-	/**
81
-	 * add server to the list of trusted Nextclouds
82
-	 *
83
-	 * @param int $id
84
-	 * @return DataResponse
85
-	 */
86
-	public function removeServer($id) {
87
-		$this->trustedServers->removeServer($id);
88
-		return new DataResponse();
89
-	}
90
-
91
-	/**
92
-	 * enable/disable to automatically add servers to the list of trusted servers
93
-	 * once a federated share was created and accepted successfully
94
-	 *
95
-	 * @param bool $autoAddServers
96
-	 */
97
-	public function autoAddServers($autoAddServers) {
98
-		$this->trustedServers->setAutoAddServers($autoAddServers);
99
-	}
100
-
101
-	/**
102
-	 * check if the server should be added to the list of trusted servers or not
103
-	 *
104
-	 * @param string $url
105
-	 * @return bool
106
-	 * @throws HintException
107
-	 */
108
-	protected function checkServer($url) {
109
-		if ($this->trustedServers->isTrustedServer($url) === true) {
110
-			$message = 'Server is already in the list of trusted servers.';
111
-			$hint = $this->l->t('Server is already in the list of trusted servers.');
112
-			throw new HintException($message, $hint);
113
-		}
114
-
115
-		if ($this->trustedServers->isOwnCloudServer($url) === false) {
116
-			$message = 'No server to federate with found';
117
-			$hint = $this->l->t('No server to federate with found');
118
-			throw new HintException($message, $hint);
119
-		}
120
-
121
-		return true;
122
-	}
37
+    /** @var IL10N */
38
+    private $l;
39
+
40
+    /** @var  TrustedServers */
41
+    private $trustedServers;
42
+
43
+    /**
44
+     * @param string $AppName
45
+     * @param IRequest $request
46
+     * @param IL10N $l10n
47
+     * @param TrustedServers $trustedServers
48
+     */
49
+    public function __construct($AppName,
50
+                                IRequest $request,
51
+                                IL10N $l10n,
52
+                                TrustedServers $trustedServers
53
+    ) {
54
+        parent::__construct($AppName, $request);
55
+        $this->l = $l10n;
56
+        $this->trustedServers = $trustedServers;
57
+    }
58
+
59
+
60
+    /**
61
+     * add server to the list of trusted Nextclouds
62
+     *
63
+     * @param string $url
64
+     * @return DataResponse
65
+     * @throws HintException
66
+     */
67
+    public function addServer($url) {
68
+        $this->checkServer($url);
69
+        $id = $this->trustedServers->addServer($url);
70
+
71
+        return new DataResponse(
72
+            [
73
+                'url' => $url,
74
+                'id' => $id,
75
+                'message' => (string) $this->l->t('Added to the list of trusted servers')
76
+            ]
77
+        );
78
+    }
79
+
80
+    /**
81
+     * add server to the list of trusted Nextclouds
82
+     *
83
+     * @param int $id
84
+     * @return DataResponse
85
+     */
86
+    public function removeServer($id) {
87
+        $this->trustedServers->removeServer($id);
88
+        return new DataResponse();
89
+    }
90
+
91
+    /**
92
+     * enable/disable to automatically add servers to the list of trusted servers
93
+     * once a federated share was created and accepted successfully
94
+     *
95
+     * @param bool $autoAddServers
96
+     */
97
+    public function autoAddServers($autoAddServers) {
98
+        $this->trustedServers->setAutoAddServers($autoAddServers);
99
+    }
100
+
101
+    /**
102
+     * check if the server should be added to the list of trusted servers or not
103
+     *
104
+     * @param string $url
105
+     * @return bool
106
+     * @throws HintException
107
+     */
108
+    protected function checkServer($url) {
109
+        if ($this->trustedServers->isTrustedServer($url) === true) {
110
+            $message = 'Server is already in the list of trusted servers.';
111
+            $hint = $this->l->t('Server is already in the list of trusted servers.');
112
+            throw new HintException($message, $hint);
113
+        }
114
+
115
+        if ($this->trustedServers->isOwnCloudServer($url) === false) {
116
+            $message = 'No server to federate with found';
117
+            $hint = $this->l->t('No server to federate with found');
118
+            throw new HintException($message, $hint);
119
+        }
120
+
121
+        return true;
122
+    }
123 123
 
124 124
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/StorageMigrator.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -42,97 +42,97 @@
 block discarded – undo
42 42
  * Migrate mount config from mount.json to the database
43 43
  */
44 44
 class StorageMigrator {
45
-	/**
46
-	 * @var BackendService
47
-	 */
48
-	private $backendService;
45
+    /**
46
+     * @var BackendService
47
+     */
48
+    private $backendService;
49 49
 
50
-	/**
51
-	 * @var DBConfigService
52
-	 */
53
-	private $dbConfig;
50
+    /**
51
+     * @var DBConfigService
52
+     */
53
+    private $dbConfig;
54 54
 
55
-	/**
56
-	 * @var IConfig
57
-	 */
58
-	private $config;
55
+    /**
56
+     * @var IConfig
57
+     */
58
+    private $config;
59 59
 
60
-	/**
61
-	 * @var IDBConnection
62
-	 */
63
-	private $connection;
60
+    /**
61
+     * @var IDBConnection
62
+     */
63
+    private $connection;
64 64
 
65
-	/**
66
-	 * @var ILogger
67
-	 */
68
-	private $logger;
65
+    /**
66
+     * @var ILogger
67
+     */
68
+    private $logger;
69 69
 
70
-	/** @var IUserMountCache  */
71
-	private $userMountCache;
70
+    /** @var IUserMountCache  */
71
+    private $userMountCache;
72 72
 
73
-	/**
74
-	 * StorageMigrator constructor.
75
-	 *
76
-	 * @param BackendService $backendService
77
-	 * @param DBConfigService $dbConfig
78
-	 * @param IConfig $config
79
-	 * @param IDBConnection $connection
80
-	 * @param ILogger $logger
81
-	 * @param IUserMountCache $userMountCache
82
-	 */
83
-	public function __construct(
84
-		BackendService $backendService,
85
-		DBConfigService $dbConfig,
86
-		IConfig $config,
87
-		IDBConnection $connection,
88
-		ILogger $logger,
89
-		IUserMountCache $userMountCache
90
-	) {
91
-		$this->backendService = $backendService;
92
-		$this->dbConfig = $dbConfig;
93
-		$this->config = $config;
94
-		$this->connection = $connection;
95
-		$this->logger = $logger;
96
-		$this->userMountCache = $userMountCache;
97
-	}
73
+    /**
74
+     * StorageMigrator constructor.
75
+     *
76
+     * @param BackendService $backendService
77
+     * @param DBConfigService $dbConfig
78
+     * @param IConfig $config
79
+     * @param IDBConnection $connection
80
+     * @param ILogger $logger
81
+     * @param IUserMountCache $userMountCache
82
+     */
83
+    public function __construct(
84
+        BackendService $backendService,
85
+        DBConfigService $dbConfig,
86
+        IConfig $config,
87
+        IDBConnection $connection,
88
+        ILogger $logger,
89
+        IUserMountCache $userMountCache
90
+    ) {
91
+        $this->backendService = $backendService;
92
+        $this->dbConfig = $dbConfig;
93
+        $this->config = $config;
94
+        $this->connection = $connection;
95
+        $this->logger = $logger;
96
+        $this->userMountCache = $userMountCache;
97
+    }
98 98
 
99
-	private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) {
100
-		$existingStorage = $legacyService->getAllStorages();
99
+    private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) {
100
+        $existingStorage = $legacyService->getAllStorages();
101 101
 
102
-		$this->connection->beginTransaction();
103
-		try {
104
-			foreach ($existingStorage as $storage) {
105
-				$mountOptions = $storage->getMountOptions();
106
-				if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) {
107
-					// existing mounts must have sharing enabled by default to avoid surprises
108
-					$mountOptions['enable_sharing'] = true;
109
-					$storage->setMountOptions($mountOptions);
110
-				}
111
-				$storageService->addStorage($storage);
112
-			}
113
-			$this->connection->commit();
114
-		} catch (\Exception $e) {
115
-			$this->logger->logException($e);
116
-			$this->connection->rollBack();
117
-		}
118
-	}
102
+        $this->connection->beginTransaction();
103
+        try {
104
+            foreach ($existingStorage as $storage) {
105
+                $mountOptions = $storage->getMountOptions();
106
+                if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) {
107
+                    // existing mounts must have sharing enabled by default to avoid surprises
108
+                    $mountOptions['enable_sharing'] = true;
109
+                    $storage->setMountOptions($mountOptions);
110
+                }
111
+                $storageService->addStorage($storage);
112
+            }
113
+            $this->connection->commit();
114
+        } catch (\Exception $e) {
115
+            $this->logger->logException($e);
116
+            $this->connection->rollBack();
117
+        }
118
+    }
119 119
 
120
-	/**
121
-	 * Migrate personal storages configured by the current user
122
-	 *
123
-	 * @param IUser $user
124
-	 */
125
-	public function migrateUser(IUser $user) {
126
-		$dummySession = new DummyUserSession();
127
-		$dummySession->setUser($user);
128
-		$userId = $user->getUID();
129
-		$userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0');
130
-		if (version_compare($userVersion, '0.5.0', '<')) {
131
-			$this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0');
132
-			$legacyService = new UserLegacyStoragesService($this->backendService, $dummySession);
133
-			$storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache);
120
+    /**
121
+     * Migrate personal storages configured by the current user
122
+     *
123
+     * @param IUser $user
124
+     */
125
+    public function migrateUser(IUser $user) {
126
+        $dummySession = new DummyUserSession();
127
+        $dummySession->setUser($user);
128
+        $userId = $user->getUID();
129
+        $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0');
130
+        if (version_compare($userVersion, '0.5.0', '<')) {
131
+            $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0');
132
+            $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession);
133
+            $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache);
134 134
 
135
-			$this->migrate($legacyService, $storageService);
136
-		}
137
-	}
135
+            $this->migrate($legacyService, $storageService);
136
+        }
137
+    }
138 138
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Scanner.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,52 +31,52 @@
 block discarded – undo
31 31
  * Scanner for SharedStorage
32 32
  */
33 33
 class Scanner extends \OC\Files\Cache\Scanner {
34
-	/**
35
-	 * @var \OCA\Files_Sharing\SharedStorage $storage
36
-	 */
37
-	protected $storage;
34
+    /**
35
+     * @var \OCA\Files_Sharing\SharedStorage $storage
36
+     */
37
+    protected $storage;
38 38
 
39
-	private $sourceScanner;
39
+    private $sourceScanner;
40 40
 
41
-	/**
42
-	 * Returns metadata from the shared storage, but
43
-	 * with permissions from the source storage.
44
-	 *
45
-	 * @param string $path path of the file for which to retrieve metadata
46
-	 *
47
-	 * @return array an array of metadata of the file
48
-	 */
49
-	public function getData($path) {
50
-		$data = parent::getData($path);
51
-		if ($data === null) {
52
-			return null;
53
-		}
54
-		$internalPath = $this->storage->getUnjailedPath($path);
55
-		$data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath);
56
-		return $data;
57
-	}
41
+    /**
42
+     * Returns metadata from the shared storage, but
43
+     * with permissions from the source storage.
44
+     *
45
+     * @param string $path path of the file for which to retrieve metadata
46
+     *
47
+     * @return array an array of metadata of the file
48
+     */
49
+    public function getData($path) {
50
+        $data = parent::getData($path);
51
+        if ($data === null) {
52
+            return null;
53
+        }
54
+        $internalPath = $this->storage->getUnjailedPath($path);
55
+        $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath);
56
+        return $data;
57
+    }
58 58
 
59
-	private function getSourceScanner() {
60
-		if ($this->sourceScanner) {
61
-			return $this->sourceScanner;
62
-		}
63
-		if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
64
-			/** @var \OC\Files\Storage\Storage $storage */
65
-			list($storage) = $this->storage->resolvePath('');
66
-			$this->sourceScanner = $storage->getScanner();
67
-			return $this->sourceScanner;
68
-		} else {
69
-			return null;
70
-		}
71
-	}
59
+    private function getSourceScanner() {
60
+        if ($this->sourceScanner) {
61
+            return $this->sourceScanner;
62
+        }
63
+        if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
64
+            /** @var \OC\Files\Storage\Storage $storage */
65
+            list($storage) = $this->storage->resolvePath('');
66
+            $this->sourceScanner = $storage->getScanner();
67
+            return $this->sourceScanner;
68
+        } else {
69
+            return null;
70
+        }
71
+    }
72 72
 
73
-	public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
74
-		$sourceScanner = $this->getSourceScanner();
75
-		if ($sourceScanner instanceof NoopScanner) {
76
-			return [];
77
-		} else {
78
-			return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
79
-		}
80
-	}
73
+    public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
74
+        $sourceScanner = $this->getSourceScanner();
75
+        if ($sourceScanner instanceof NoopScanner) {
76
+            return [];
77
+        } else {
78
+            return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
79
+        }
80
+    }
81 81
 }
82 82
 
Please login to merge, or discard this patch.
apps/testing/lib/Controller/RateLimitTestController.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,28 +25,28 @@
 block discarded – undo
25 25
 use OCP\AppFramework\Http\JSONResponse;
26 26
 
27 27
 class RateLimitTestController extends Controller {
28
-	/**
29
-	 * @PublicPage
30
-	 * @NoCSRFRequired
31
-	 *
32
-	 * @UserRateThrottle(limit=5, period=100)
33
-	 * @AnonRateThrottle(limit=1, period=100)
34
-	 *
35
-	 * @return JSONResponse
36
-	 */
37
-	public function userAndAnonProtected() {
38
-		return new JSONResponse();
39
-	}
28
+    /**
29
+     * @PublicPage
30
+     * @NoCSRFRequired
31
+     *
32
+     * @UserRateThrottle(limit=5, period=100)
33
+     * @AnonRateThrottle(limit=1, period=100)
34
+     *
35
+     * @return JSONResponse
36
+     */
37
+    public function userAndAnonProtected() {
38
+        return new JSONResponse();
39
+    }
40 40
 
41
-	/**
42
-	 * @PublicPage
43
-	 * @NoCSRFRequired
44
-	 *
45
-	 * @AnonRateThrottle(limit=1, period=10)
46
-	 *
47
-	 * @return JSONResponse
48
-	 */
49
-	public function onlyAnonProtected() {
50
-		return new JSONResponse();
51
-	}
41
+    /**
42
+     * @PublicPage
43
+     * @NoCSRFRequired
44
+     *
45
+     * @AnonRateThrottle(limit=1, period=10)
46
+     *
47
+     * @return JSONResponse
48
+     */
49
+    public function onlyAnonProtected() {
50
+        return new JSONResponse();
51
+    }
52 52
 }
Please login to merge, or discard this patch.
lib/private/Security/RateLimiting/Exception/RateLimitExceededException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 use OCP\AppFramework\Http;
26 26
 
27 27
 class RateLimitExceededException extends SecurityException {
28
-	public function __construct() {
29
-		parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS);
30
-	}
28
+    public function __construct() {
29
+        parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS);
30
+    }
31 31
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -48,87 +48,87 @@
 block discarded – undo
48 48
  * @package OC\AppFramework\Middleware\Security
49 49
  */
50 50
 class RateLimitingMiddleware extends Middleware {
51
-	/** @var IRequest $request */
52
-	private $request;
53
-	/** @var IUserSession */
54
-	private $userSession;
55
-	/** @var ControllerMethodReflector */
56
-	private $reflector;
57
-	/** @var Limiter */
58
-	private $limiter;
51
+    /** @var IRequest $request */
52
+    private $request;
53
+    /** @var IUserSession */
54
+    private $userSession;
55
+    /** @var ControllerMethodReflector */
56
+    private $reflector;
57
+    /** @var Limiter */
58
+    private $limiter;
59 59
 
60
-	/**
61
-	 * @param IRequest $request
62
-	 * @param IUserSession $userSession
63
-	 * @param ControllerMethodReflector $reflector
64
-	 * @param Limiter $limiter
65
-	 */
66
-	public function __construct(IRequest $request,
67
-								IUserSession $userSession,
68
-								ControllerMethodReflector $reflector,
69
-								Limiter $limiter) {
70
-		$this->request = $request;
71
-		$this->userSession = $userSession;
72
-		$this->reflector = $reflector;
73
-		$this->limiter = $limiter;
74
-	}
60
+    /**
61
+     * @param IRequest $request
62
+     * @param IUserSession $userSession
63
+     * @param ControllerMethodReflector $reflector
64
+     * @param Limiter $limiter
65
+     */
66
+    public function __construct(IRequest $request,
67
+                                IUserSession $userSession,
68
+                                ControllerMethodReflector $reflector,
69
+                                Limiter $limiter) {
70
+        $this->request = $request;
71
+        $this->userSession = $userSession;
72
+        $this->reflector = $reflector;
73
+        $this->limiter = $limiter;
74
+    }
75 75
 
76
-	/**
77
-	 * {@inheritDoc}
78
-	 * @throws RateLimitExceededException
79
-	 */
80
-	public function beforeController($controller, $methodName) {
81
-		parent::beforeController($controller, $methodName);
76
+    /**
77
+     * {@inheritDoc}
78
+     * @throws RateLimitExceededException
79
+     */
80
+    public function beforeController($controller, $methodName) {
81
+        parent::beforeController($controller, $methodName);
82 82
 
83
-		$anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit');
84
-		$anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
85
-		$userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
86
-		$userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
87
-		$rateLimitIdentifier = get_class($controller) . '::' . $methodName;
88
-		if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
89
-			$this->limiter->registerUserRequest(
90
-				$rateLimitIdentifier,
91
-				$userLimit,
92
-				$userPeriod,
93
-				$this->userSession->getUser()
94
-			);
95
-		} elseif ($anonLimit !== '' && $anonPeriod !== '') {
96
-			$this->limiter->registerAnonRequest(
97
-				$rateLimitIdentifier,
98
-				$anonLimit,
99
-				$anonPeriod,
100
-				$this->request->getRemoteAddress()
101
-			);
102
-		}
103
-	}
83
+        $anonLimit = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'limit');
84
+        $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
85
+        $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
86
+        $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
87
+        $rateLimitIdentifier = get_class($controller) . '::' . $methodName;
88
+        if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
89
+            $this->limiter->registerUserRequest(
90
+                $rateLimitIdentifier,
91
+                $userLimit,
92
+                $userPeriod,
93
+                $this->userSession->getUser()
94
+            );
95
+        } elseif ($anonLimit !== '' && $anonPeriod !== '') {
96
+            $this->limiter->registerAnonRequest(
97
+                $rateLimitIdentifier,
98
+                $anonLimit,
99
+                $anonPeriod,
100
+                $this->request->getRemoteAddress()
101
+            );
102
+        }
103
+    }
104 104
 
105
-	/**
106
-	 * {@inheritDoc}
107
-	 */
108
-	public function afterException($controller, $methodName, \Exception $exception) {
109
-		if($exception instanceof RateLimitExceededException) {
110
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
111
-				$response = new JSONResponse(
112
-					[
113
-						'message' => $exception->getMessage(),
114
-					],
115
-					$exception->getCode()
116
-				);
117
-			} else {
118
-					$response = new TemplateResponse(
119
-						'core',
120
-						'403',
121
-							[
122
-								'file' => $exception->getMessage()
123
-							],
124
-						'guest'
125
-					);
126
-					$response->setStatus($exception->getCode());
127
-			}
105
+    /**
106
+     * {@inheritDoc}
107
+     */
108
+    public function afterException($controller, $methodName, \Exception $exception) {
109
+        if($exception instanceof RateLimitExceededException) {
110
+            if (stripos($this->request->getHeader('Accept'),'html') === false) {
111
+                $response = new JSONResponse(
112
+                    [
113
+                        'message' => $exception->getMessage(),
114
+                    ],
115
+                    $exception->getCode()
116
+                );
117
+            } else {
118
+                    $response = new TemplateResponse(
119
+                        'core',
120
+                        '403',
121
+                            [
122
+                                'file' => $exception->getMessage()
123
+                            ],
124
+                        'guest'
125
+                    );
126
+                    $response->setStatus($exception->getCode());
127
+            }
128 128
 
129
-			return $response;
130
-		}
129
+            return $response;
130
+        }
131 131
 
132
-		throw $exception;
133
-	}
132
+        throw $exception;
133
+    }
134 134
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 		$anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period');
85 85
 		$userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit');
86 86
 		$userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period');
87
-		$rateLimitIdentifier = get_class($controller) . '::' . $methodName;
88
-		if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
87
+		$rateLimitIdentifier = get_class($controller).'::'.$methodName;
88
+		if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) {
89 89
 			$this->limiter->registerUserRequest(
90 90
 				$rateLimitIdentifier,
91 91
 				$userLimit,
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 * {@inheritDoc}
107 107
 	 */
108 108
 	public function afterException($controller, $methodName, \Exception $exception) {
109
-		if($exception instanceof RateLimitExceededException) {
110
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
109
+		if ($exception instanceof RateLimitExceededException) {
110
+			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
111 111
 				$response = new JSONResponse(
112 112
 					[
113 113
 						'message' => $exception->getMessage(),
Please login to merge, or discard this patch.
settings/Activity/Setting.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -26,71 +26,71 @@
 block discarded – undo
26 26
 
27 27
 class Setting implements ISetting {
28 28
 
29
-	/** @var IL10N */
30
-	protected $l;
29
+    /** @var IL10N */
30
+    protected $l;
31 31
 
32
-	/**
33
-	 * @param IL10N $l10n
34
-	 */
35
-	public function __construct(IL10N $l10n) {
36
-		$this->l = $l10n;
37
-	}
32
+    /**
33
+     * @param IL10N $l10n
34
+     */
35
+    public function __construct(IL10N $l10n) {
36
+        $this->l = $l10n;
37
+    }
38 38
 
39
-	/**
40
-	 * @return string Lowercase a-z and underscore only identifier
41
-	 * @since 11.0.0
42
-	 */
43
-	public function getIdentifier() {
44
-		return 'personal_settings';
45
-	}
39
+    /**
40
+     * @return string Lowercase a-z and underscore only identifier
41
+     * @since 11.0.0
42
+     */
43
+    public function getIdentifier() {
44
+        return 'personal_settings';
45
+    }
46 46
 
47
-	/**
48
-	 * @return string A translated string
49
-	 * @since 11.0.0
50
-	 */
51
-	public function getName() {
52
-		return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified');
53
-	}
47
+    /**
48
+     * @return string A translated string
49
+     * @since 11.0.0
50
+     */
51
+    public function getName() {
52
+        return $this->l->t('Your <strong>password</strong> or <strong>email</strong> was modified');
53
+    }
54 54
 
55
-	/**
56
-	 * @return int whether the filter should be rather on the top or bottom of
57
-	 * the admin section. The filters are arranged in ascending order of the
58
-	 * priority values. It is required to return a value between 0 and 100.
59
-	 * @since 11.0.0
60
-	 */
61
-	public function getPriority() {
62
-		return 0;
63
-	}
55
+    /**
56
+     * @return int whether the filter should be rather on the top or bottom of
57
+     * the admin section. The filters are arranged in ascending order of the
58
+     * priority values. It is required to return a value between 0 and 100.
59
+     * @since 11.0.0
60
+     */
61
+    public function getPriority() {
62
+        return 0;
63
+    }
64 64
 
65
-	/**
66
-	 * @return bool True when the option can be changed for the stream
67
-	 * @since 11.0.0
68
-	 */
69
-	public function canChangeStream() {
70
-		return false;
71
-	}
65
+    /**
66
+     * @return bool True when the option can be changed for the stream
67
+     * @since 11.0.0
68
+     */
69
+    public function canChangeStream() {
70
+        return false;
71
+    }
72 72
 
73
-	/**
74
-	 * @return bool True when the option can be changed for the stream
75
-	 * @since 11.0.0
76
-	 */
77
-	public function isDefaultEnabledStream() {
78
-		return true;
79
-	}
73
+    /**
74
+     * @return bool True when the option can be changed for the stream
75
+     * @since 11.0.0
76
+     */
77
+    public function isDefaultEnabledStream() {
78
+        return true;
79
+    }
80 80
 
81
-	/**
82
-	 * @return bool True when the option can be changed for the mail
83
-	 * @since 11.0.0
84
-	 */
85
-	public function canChangeMail() {
86
-		return false;
87
-	}
81
+    /**
82
+     * @return bool True when the option can be changed for the mail
83
+     * @since 11.0.0
84
+     */
85
+    public function canChangeMail() {
86
+        return false;
87
+    }
88 88
 
89
-	/**
90
-	 * @return bool True when the option can be changed for the stream
91
-	 * @since 11.0.0
92
-	 */
93
-	public function isDefaultEnabledMail() {
94
-		return false;
95
-	}
89
+    /**
90
+     * @return bool True when the option can be changed for the stream
91
+     * @since 11.0.0
92
+     */
93
+    public function isDefaultEnabledMail() {
94
+        return false;
95
+    }
96 96
 }
Please login to merge, or discard this patch.