[Pkg-owncloud-commits] [owncloud] 84/223: more style fixes

David Prévot taffit at moszumanska.debian.org
Sun Jun 22 01:54:09 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 2b2b1b487c6b74d442a70ebb0468a8990c26d08d
Author: Bernhard Posselt <dev at bernhard-posselt.com>
Date:   Fri Jun 6 16:51:58 2014 +0200

    more style fixes
---
 core/lostpassword/controller/lostcontroller.php | 39 +++++++++++++++----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/core/lostpassword/controller/lostcontroller.php b/core/lostpassword/controller/lostcontroller.php
index 6635f8d..c140499 100644
--- a/core/lostpassword/controller/lostcontroller.php
+++ b/core/lostpassword/controller/lostcontroller.php
@@ -71,6 +71,14 @@ class LostController extends Controller {
 		);
 	}
 
+	private function error($message, array $additional=array()) {
+		return array_combine(array('status' => 'error', 'msg' => $message), $additional);
+	}
+
+	private function success() {
+		return array('status'=>'success');
+	}
+
 	/**
 	 * @PublicPage
 	 *
@@ -82,39 +90,36 @@ class LostController extends Controller {
 		try {
 			$this->sendEmail($user, $proceed);
 		} catch (EncryptedDataException $e){
-			array('status' => 'error', 'encryption' => '1');
+			return $this->error('', array('encryption' => '1'));
 		} catch (\Exception $e){
-			return array('status' => 'error', 'msg' => $e->getMessage());
+			return $this->error($e->getMessage());
 		}
 
-		return array('status'=>'success');
+		return $this->success();
 	}
 
 
 	/**
 	 * @PublicPage
 	 */
-	public function setPassword($token, $uid, $password) {
+	public function setPassword($token, $userId, $password) {
 		try {
-			if (!$this->checkToken($uid, $token)) {
-				throw new \Exception();
-			}
-
-			$user = $this->userManager->get($uid);
-			if (!$user->setPassword($uid, $password)) {
+			$user = $this->userManager->get($userId);
 
+			if (!$this->checkToken($userId, $token) ||
+				!$user->setPassword($userId, $password)) {
 				throw new \Exception();
 			}
 
 			// FIXME: should be added to the all config at some point
-			\OC_Preferences::deleteKey($uid, 'owncloud', 'lostpassword');
+			\OC_Preferences::deleteKey($userId, 'owncloud', 'lostpassword');
 			$this->userSession->unsetMagicInCookie();
 
 		} catch (\Exception $e){
-			return array('status' => 'error','msg' => $e->getMessage());
+			return $this->error($e->getMessage());
 		}
 
-		return array('status'=>'success');
+		return $this->success();
 	}
 
 
@@ -153,6 +158,7 @@ class LostController extends Controller {
 		$msg = $tmpl->fetchPage();
 
 		try {
+			// FIXME: should be added to the container and injected in here
 			\OC_Mail::send($email, $user, $this->l10n->t(
 				'%s password reset',
 				array(
@@ -162,8 +168,9 @@ class LostController extends Controller {
 					$this->defaults->getName()
 				));
 		} catch (\Exception $e) {
-			throw new \Exception($this->l10n->t('Couldn’t send reset email. ' .
-				                                'Please contact your administrator.'));
+			throw new \Exception($this->l10n->t(
+				'Couldn’t send reset email. Please contact your administrator.'
+			));
 		}
 	}
 
@@ -174,6 +181,7 @@ class LostController extends Controller {
 			'uid' => $user
 		);
 		$link = $this->urlGenerator->linkToRoute($route, $parameters);
+
 		return $this->urlGenerator->getAbsoluteUrl($link);
 	}
 
@@ -184,4 +192,5 @@ class LostController extends Controller {
 		) === hash('sha256', $token);
 	}
 
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list