aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-11-17 09:40:16 +0100
committerGitHub <noreply@github.com>2016-11-17 09:40:16 +0100
commitde983e61e3660964154d1c7f447ca8a2055cc2d6 (patch)
tree806c18ae78a6a0e1d2ec67a3640b1a3a07ddae27 /core
parentf264715b3e1062287d8bbb5e2b40bcaf6676802f (diff)
parent74c68d87613cd4517c6853096af7d332855cffdf (diff)
downloadnextcloud-server-de983e61e3660964154d1c7f447ca8a2055cc2d6.tar.gz
nextcloud-server-de983e61e3660964154d1c7f447ca8a2055cc2d6.zip
Merge pull request #2170 from nextcloud/ocs_person_to_controller
OCS person to controller
Diffstat (limited to 'core')
-rw-r--r--core/Controller/OCSController.php39
-rw-r--r--core/routes.php1
2 files changed, 39 insertions, 1 deletions
diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php
index 13cc4d8ce2c..27ab9deb08a 100644
--- a/core/Controller/OCSController.php
+++ b/core/Controller/OCSController.php
@@ -22,8 +22,10 @@
namespace OC\Core\Controller;
use OC\CapabilitiesManager;
+use OC\Security\Bruteforce\Throttler;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
+use OCP\IUserManager;
use OCP\IUserSession;
class OCSController extends \OCP\AppFramework\OCSController {
@@ -34,6 +36,12 @@ class OCSController extends \OCP\AppFramework\OCSController {
/** @var IUserSession */
private $userSession;
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var Throttler */
+ private $throttler;
+
/**
* OCSController constructor.
*
@@ -41,15 +49,21 @@ class OCSController extends \OCP\AppFramework\OCSController {
* @param IRequest $request
* @param CapabilitiesManager $capabilitiesManager
* @param IUserSession $userSession
+ * @param IUserManager $userManager
+ * @param Throttler $throttler
*/
public function __construct($appName,
IRequest $request,
CapabilitiesManager $capabilitiesManager,
- IUserSession $userSession) {
+ IUserSession $userSession,
+ IUserManager $userManager,
+ Throttler $throttler) {
parent::__construct($appName, $request);
$this->capabilitiesManager = $capabilitiesManager;
$this->userSession = $userSession;
+ $this->userManager = $userManager;
+ $this->throttler = $throttler;
}
/**
@@ -102,4 +116,27 @@ class OCSController extends \OCP\AppFramework\OCSController {
];
return new DataResponse($data);
}
+
+ /**
+ * @PublicPage
+ *
+ * @param string $login
+ * @param string $password
+ * @return DataResponse
+ */
+ public function personCheck($login = '', $password = '') {
+ if ($login !== '' && $password !== '') {
+ $this->throttler->sleepDelay($this->request->getRemoteAddress());
+ if ($this->userManager->checkPassword($login, $password)) {
+ return new DataResponse([
+ 'person' => [
+ 'personid' => $login
+ ]
+ ]);
+ }
+ $this->throttler->registerAttempt('login', $this->request->getRemoteAddress());
+ return new DataResponse(null, 102);
+ }
+ return new DataResponse(null, 101);
+ }
}
diff --git a/core/routes.php b/core/routes.php
index c890d232cfe..2ddd77c1445 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -59,6 +59,7 @@ $application->registerRoutes($this, [
['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'OCS#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
+ ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
],
]);