Completed
Push — stable13 ( 329c21...e3a2b9 )
by Roeland
84:33
created
core/Controller/LostController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function checkPasswordResetToken($token, $userId) {
172 172
 		$user = $this->userManager->get($userId);
173
-		if($user === null || !$user->isEnabled()) {
173
+		if ($user === null || !$user->isEnabled()) {
174 174
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
175 175
 		}
176 176
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 		}
184 184
 
185 185
 		$splittedToken = explode(':', $decryptedToken);
186
-		if(count($splittedToken) !== 2) {
186
+		if (count($splittedToken) !== 2) {
187 187
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
188 188
 		}
189 189
 
190
-		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*24*7) ||
190
+		if ($splittedToken[0] < ($this->timeFactory->getTime() - 60 * 60 * 24 * 7) ||
191 191
 			$user->getLastLogin() > $splittedToken[0]) {
192 192
 			throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
193 193
 		}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @param array $additional
203 203
 	 * @return array
204 204
 	 */
205
-	private function error($message, array $additional=array()) {
205
+	private function error($message, array $additional = array()) {
206 206
 		return array_merge(array('status' => 'error', 'msg' => $message), $additional);
207 207
 	}
208 208
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @param string $user
223 223
 	 * @return JSONResponse
224 224
 	 */
225
-	public function email($user){
225
+	public function email($user) {
226 226
 		if ($this->config->getSystemValue('lost_password_link', '') !== '') {
227 227
 			return new JSONResponse($this->error($this->l10n->t('Password reset is disabled')));
228 228
 		}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		// FIXME: use HTTP error codes
237 237
 		try {
238 238
 			$this->sendEmail($user);
239
-		} catch (\Exception $e){
239
+		} catch (\Exception $e) {
240 240
 			$response = new JSONResponse($this->error($e->getMessage()));
241 241
 			$response->throttle();
242 242
 			return $response;
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 
287 287
 			$this->config->deleteUserValue($userId, 'core', 'lostpassword');
288 288
 			@\OC::$server->getUserSession()->unsetMagicInCookie();
289
-		} catch (HintException $e){
289
+		} catch (HintException $e) {
290 290
 			return $this->error($e->getHint());
291
-		} catch (\Exception $e){
291
+		} catch (\Exception $e) {
292 292
 			return $this->error($e->getMessage());
293 293
 		}
294 294
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 			ISecureRandom::CHAR_LOWER.
320 320
 			ISecureRandom::CHAR_UPPER
321 321
 		);
322
-		$tokenValue = $this->timeFactory->getTime() .':'. $token;
323
-		$encryptedValue = $this->crypto->encrypt($tokenValue, $email . $this->config->getSystemValue('secret'));
322
+		$tokenValue = $this->timeFactory->getTime().':'.$token;
323
+		$encryptedValue = $this->crypto->encrypt($tokenValue, $email.$this->config->getSystemValue('secret'));
324 324
 		$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
325 325
 
326 326
 		$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user->getUID(), 'token' => $token));
Please login to merge, or discard this patch.