aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-07-19 18:28:06 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-08-01 08:20:15 +0200
commitc25e782dd6c85a29a39b18fddc3946fc1528a810 (patch)
treeab76c8f36336ba959dea7f0b47f549bdca04d3e3
parente1da8a769bd25a8542109383e20565d6792a7299 (diff)
downloadnextcloud-server-c25e782dd6c85a29a39b18fddc3946fc1528a810.tar.gz
nextcloud-server-c25e782dd6c85a29a39b18fddc3946fc1528a810.zip
Fix settings/Controller/
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
-rw-r--r--settings/Controller/AuthSettingsController.php12
-rw-r--r--settings/Controller/CertificateController.php10
-rw-r--r--settings/Controller/ChangePasswordController.php19
-rw-r--r--tests/Core/Controller/ChangePasswordControllerTest.php4
4 files changed, 25 insertions, 20 deletions
diff --git a/settings/Controller/AuthSettingsController.php b/settings/Controller/AuthSettingsController.php
index d1ce567afb9..7b68fc4c289 100644
--- a/settings/Controller/AuthSettingsController.php
+++ b/settings/Controller/AuthSettingsController.php
@@ -76,11 +76,11 @@ class AuthSettingsController extends Controller {
* @NoAdminRequired
* @NoSubadminRequired
*
- * @return JSONResponse
+ * @return JSONResponse|array
*/
public function index() {
$user = $this->userManager->get($this->uid);
- if (is_null($user)) {
+ if ($user === null) {
return [];
}
$tokens = $this->tokenProvider->getTokenByUser($user);
@@ -147,6 +147,9 @@ class AuthSettingsController extends Controller {
]);
}
+ /**
+ * @return JSONResponse
+ */
private function getServiceNotAvailableResponse() {
$resp = new JSONResponse();
$resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
@@ -172,7 +175,7 @@ class AuthSettingsController extends Controller {
* @NoAdminRequired
* @NoSubadminRequired
*
- * @return JSONResponse
+ * @return array
*/
public function destroy($id) {
$user = $this->userManager->get($this->uid);
@@ -190,9 +193,10 @@ class AuthSettingsController extends Controller {
*
* @param int $id
* @param array $scope
+ * @return array
*/
public function update($id, array $scope) {
- $token = $this->tokenProvider->getTokenById($id);
+ $token = $this->tokenProvider->getTokenById((string)$id);
$token->setScope([
'filesystem' => $scope['filesystem']
]);
diff --git a/settings/Controller/CertificateController.php b/settings/Controller/CertificateController.php
index 1cf9e03effb..c5f7e89f3fc 100644
--- a/settings/Controller/CertificateController.php
+++ b/settings/Controller/CertificateController.php
@@ -72,7 +72,7 @@ class CertificateController extends Controller {
*
* @NoAdminRequired
* @NoSubadminRequired
- * @return array
+ * @return DataResponse
*/
public function addPersonalRootCertificate() {
return $this->addCertificate($this->userCertificateManager);
@@ -114,7 +114,7 @@ class CertificateController extends Controller {
$headers
);
} catch (\Exception $e) {
- return new DataResponse('An error occurred.', Http::STATUS_UNPROCESSABLE_ENTITY, $headers);
+ return new DataResponse(['An error occurred.'], Http::STATUS_UNPROCESSABLE_ENTITY, $headers);
}
}
@@ -129,7 +129,7 @@ class CertificateController extends Controller {
public function removePersonalRootCertificate($certificateIdentifier) {
if ($this->isCertificateImportAllowed() === false) {
- return new DataResponse('Individual certificate management disabled', Http::STATUS_FORBIDDEN);
+ return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN);
}
$this->userCertificateManager->removeCertificate($certificateIdentifier);
@@ -156,7 +156,7 @@ class CertificateController extends Controller {
/**
* Add a new personal root certificate to the system's trust store
*
- * @return array
+ * @return DataResponse
*/
public function addSystemRootCertificate() {
return $this->addCertificate($this->systemCertificateManager);
@@ -171,7 +171,7 @@ class CertificateController extends Controller {
public function removeSystemRootCertificate($certificateIdentifier) {
if ($this->isCertificateImportAllowed() === false) {
- return new DataResponse('Individual certificate management disabled', Http::STATUS_FORBIDDEN);
+ return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN);
}
$this->systemCertificateManager->removeCertificate($certificateIdentifier);
diff --git a/settings/Controller/ChangePasswordController.php b/settings/Controller/ChangePasswordController.php
index cb1a97386a6..e0129af50f1 100644
--- a/settings/Controller/ChangePasswordController.php
+++ b/settings/Controller/ChangePasswordController.php
@@ -22,14 +22,15 @@
namespace OC\Settings\Controller;
use OC\HintException;
+use OC\User\Manager as UserManager;
+use OC\Group\Manager as GroupManager;
+use OC\User\Session;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
-use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
-use OCP\IUserManager;
use OCP\IUserSession;
class ChangePasswordController extends Controller {
@@ -37,16 +38,16 @@ class ChangePasswordController extends Controller {
/** @var string */
private $userId;
- /** @var IUserManager */
+ /** @var UserManager */
private $userManager;
/** @var IL10N */
private $l;
- /** @var IGroupManager */
+ /** @var GroupManager */
private $groupManager;
- /** @var IUserSession */
+ /** @var Session */
private $userSession;
/** @var IAppManager */
@@ -58,18 +59,18 @@ class ChangePasswordController extends Controller {
* @param string $appName
* @param IRequest $request
* @param $userId
- * @param IUserManager $userManager
+ * @param UserManager $userManager
* @param IUserSession $userSession
- * @param IGroupManager $groupManager
+ * @param GroupManager $groupManager
* @param IAppManager $appManager
* @param IL10N $l
*/
public function __construct($appName,
IRequest $request,
$userId,
- IUserManager $userManager,
+ UserManager $userManager,
IUserSession $userSession,
- IGroupManager $groupManager,
+ GroupManager $groupManager,
IAppManager $appManager,
IL10N $l) {
parent::__construct($appName, $request);
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php
index c426bae9974..ea3abb58e2f 100644
--- a/tests/Core/Controller/ChangePasswordControllerTest.php
+++ b/tests/Core/Controller/ChangePasswordControllerTest.php
@@ -50,9 +50,9 @@ class ChangePasswordControllerTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->userManager = $this->createMock(IUserManager::class);
+ $this->userManager = $this->createMock(\OC\User\Manager::class);
$this->userSession = $this->createMock(Session::class);
- $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->groupManager = $this->createMock(\OC\Group\Manager::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')->will($this->returnArgument(0));