Completed
Pull Request — master (#9531)
by Rémy
14:51
created
core/Controller/LostController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	protected function checkPasswordResetToken($token, $userId) {
171 171
 		$user = $this->userManager->get($userId);
172
-		if($user === null || !$user->isEnabled()) {
172
+		if ($user === null || !$user->isEnabled()) {
173 173
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
174 174
 		}
175 175
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 
184 184
 		$splittedToken = explode(':', $decryptedToken);
185
-		if(count($splittedToken) !== 2) {
185
+		if (count($splittedToken) !== 2) {
186 186
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
187 187
 		}
188 188
 
189
-		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) ||
189
+		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60 * 60 * 12) ||
190 190
 			$user->getLastLogin() > $splittedToken[0]) {
191 191
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
192 192
 		}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @param array $additional
202 202
 	 * @return array
203 203
 	 */
204
-	private function error($message, array $additional=array()) {
204
+	private function error($message, array $additional = array()) {
205 205
 		return array_merge(array('status' => 'error', 'msg' => $message), $additional);
206 206
 	}
207 207
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param string $user
221 221
 	 * @return JSONResponse
222 222
 	 */
223
-	public function email($user){
223
+	public function email($user) {
224 224
 		if ($this->config->getSystemValue('lost_password_link', '') !== '') {
225 225
 			return new JSONResponse($this->error($this->l10n->t('Password reset is disabled')));
226 226
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		// FIXME: use HTTP error codes
235 235
 		try {
236 236
 			$this->sendEmail($user);
237
-		} catch (\Exception $e){
237
+		} catch (\Exception $e) {
238 238
 			$response = new JSONResponse($this->error($e->getMessage()));
239 239
 			$response->throttle();
240 240
 			return $response;
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 
277 277
 			$this->config->deleteUserValue($userId, 'core', 'lostpassword');
278 278
 			@\OC::$server->getUserSession()->unsetMagicInCookie();
279
-		} catch (HintException $e){
279
+		} catch (HintException $e) {
280 280
 			return $this->error($e->getHint());
281
-		} catch (\Exception $e){
281
+		} catch (\Exception $e) {
282 282
 			return $this->error($e->getMessage());
283 283
 		}
284 284
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 			ISecureRandom::CHAR_LOWER.
310 310
 			ISecureRandom::CHAR_UPPER
311 311
 		);
312
-		$tokenValue = $this->timeFactory->getTime() .':'. $token;
313
-		$encryptedValue = $this->crypto->encrypt($tokenValue, $email . $this->config->getSystemValue('secret'));
312
+		$tokenValue = $this->timeFactory->getTime().':'.$token;
313
+		$encryptedValue = $this->crypto->encrypt($tokenValue, $email.$this->config->getSystemValue('secret'));
314 314
 		$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
315 315
 
316 316
 		$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user->getUID(), 'token' => $token));
Please login to merge, or discard this patch.