diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-16 19:21:00 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-16 19:21:00 +0100 |
commit | 1baa2b8deb658b888614bbbb16f64ec22309612a (patch) | |
tree | 25455418697de3887436996b4dc23d594653bd3f /core/Controller/OCSController.php | |
parent | cc8750ca30ba5d13ca59cc8c3ce87122a451829a (diff) | |
download | nextcloud-server-1baa2b8deb658b888614bbbb16f64ec22309612a.tar.gz nextcloud-server-1baa2b8deb658b888614bbbb16f64ec22309612a.zip |
Move OC\OCS\Person to OCSController
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/Controller/OCSController.php')
-rw-r--r-- | core/Controller/OCSController.php | 39 |
1 files changed, 38 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); + } } |