diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/Application.php | 113 | ||||
-rw-r--r-- | core/Controller/LoginController.php | 8 | ||||
-rw-r--r-- | core/Controller/LostController.php | 19 | ||||
-rw-r--r-- | core/Controller/TokenController.php | 8 |
4 files changed, 26 insertions, 122 deletions
diff --git a/core/Application.php b/core/Application.php index 9a6d0878fee..4fa83f09854 100644 --- a/core/Application.php +++ b/core/Application.php @@ -1,6 +1,7 @@ <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> * * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Christoph Wurst <christoph@owncloud.com> @@ -29,13 +30,8 @@ namespace OC\Core; -use OC\AppFramework\Utility\SimpleContainer; -use OC\AppFramework\Utility\TimeFactory; -use OC\Core\Controller\LoginController; -use OC\Core\Controller\LostController; -use OC\Core\Controller\TokenController; -use OC\Core\Controller\TwoFactorChallengeController; -use OC\Core\Controller\UserController; +use OC\Authentication\Token\DefaultTokenProvider; +use OC\Authentication\Token\IProvider; use OCP\AppFramework\App; use OCP\Util; @@ -46,108 +42,13 @@ use OCP\Util; */ class Application extends App { - /** - * @param array $urlParams - */ - public function __construct(array $urlParams=array()){ - parent::__construct('core', $urlParams); + public function __construct() { + parent::__construct('core'); $container = $this->getContainer(); - - /** - * Controllers - */ - $container->registerService('LostController', function(SimpleContainer $c) { - return new LostController( - $c->query('AppName'), - $c->query('Request'), - $c->query('URLGenerator'), - $c->query('UserManager'), - $c->query('Defaults'), - $c->query('L10N'), - $c->query('Config'), - $c->query('SecureRandom'), - $c->query('DefaultEmailAddress'), - $c->query('IsEncryptionEnabled'), - $c->query('Mailer'), - $c->query('TimeFactory') - ); - }); - $container->registerService('LoginController', function(SimpleContainer $c) { - return new LoginController( - $c->query('AppName'), - $c->query('Request'), - $c->query('UserManager'), - $c->query('Config'), - $c->query('Session'), - $c->query('UserSession'), - $c->query('URLGenerator'), - $c->query('TwoFactorAuthManager'), - $c->query('ServerContainer')->getBruteforceThrottler() - ); - }); - $container->registerService('TwoFactorChallengeController', function (SimpleContainer $c) { - return new TwoFactorChallengeController( - $c->query('AppName'), - $c->query('Request'), - $c->query('TwoFactorAuthManager'), - $c->query('UserSession'), - $c->query('Session'), - $c->query('URLGenerator')); - }); - $container->registerService('TokenController', function(SimpleContainer $c) { - return new TokenController( - $c->query('AppName'), - $c->query('Request'), - $c->query('UserManager'), - $c->query('ServerContainer')->query('OC\Authentication\Token\IProvider'), - $c->query('TwoFactorAuthManager'), - $c->query('SecureRandom') - ); - }); - - /** - * Core class wrappers - */ - $container->registerService('IsEncryptionEnabled', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getEncryptionManager()->isEnabled(); - }); - $container->registerService('URLGenerator', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getURLGenerator(); - }); - $container->registerService('UserManager', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getUserManager(); - }); - $container->registerService('Config', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getConfig(); - }); - $container->registerService('L10N', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getL10N('core'); - }); - $container->registerService('SecureRandom', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getSecureRandom(); - }); - $container->registerService('Session', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getSession(); - }); - $container->registerService('UserSession', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getUserSession(); - }); - $container->registerService('Defaults', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getThemingDefaults(); - }); - $container->registerService('Mailer', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getMailer(); - }); - $container->registerService('TimeFactory', function(SimpleContainer $c) { - return new TimeFactory(); - }); - $container->registerService('DefaultEmailAddress', function() { + $container->registerService('defaultMailAddress', function() { return Util::getDefaultEmailAddress('lostpassword-noreply'); }); - $container->registerService('TwoFactorAuthManager', function(SimpleContainer $c) { - return $c->query('ServerContainer')->getTwoFactorAuthManager(); - }); + $container->registerAlias(IProvider::class, DefaultTokenProvider::class); } - } diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php index 083f4bb0518..884eea8869e 100644 --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php @@ -33,12 +33,14 @@ use OC_Util; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\IConfig; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; +use OCP\IUserSession; class LoginController extends Controller { /** @var IUserManager */ @@ -47,7 +49,7 @@ class LoginController extends Controller { private $config; /** @var ISession */ private $session; - /** @var Session */ + /** @var IUserSession|Session */ private $userSession; /** @var IURLGenerator */ private $urlGenerator; @@ -62,7 +64,7 @@ class LoginController extends Controller { * @param IUserManager $userManager * @param IConfig $config * @param ISession $session - * @param Session $userSession + * @param IUserSession $userSession * @param IURLGenerator $urlGenerator * @param Manager $twoFactorManager * @param Throttler $throttler @@ -72,7 +74,7 @@ class LoginController extends Controller { IUserManager $userManager, IConfig $config, ISession $session, - Session $userSession, + IUserSession $userSession, IURLGenerator $urlGenerator, Manager $twoFactorManager, Throttler $throttler) { diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php index b1111559a6c..bfc24bd1e0f 100644 --- a/core/Controller/LostController.php +++ b/core/Controller/LostController.php @@ -33,6 +33,7 @@ namespace OC\Core\Controller; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Encryption\IManager; use \OCP\IURLGenerator; use \OCP\IRequest; use \OCP\IL10N; @@ -60,8 +61,8 @@ class LostController extends Controller { protected $l10n; /** @var string */ protected $from; - /** @var bool */ - protected $isDataEncrypted; + /** @var IManager */ + protected $encryptionManager; /** @var IConfig */ protected $config; /** @var ISecureRandom */ @@ -80,8 +81,8 @@ class LostController extends Controller { * @param IL10N $l10n * @param IConfig $config * @param ISecureRandom $secureRandom - * @param string $from - * @param string $isDataEncrypted + * @param string $defaultMailAddress + * @param IManager $encryptionManager * @param IMailer $mailer * @param ITimeFactory $timeFactory */ @@ -93,8 +94,8 @@ class LostController extends Controller { IL10N $l10n, IConfig $config, ISecureRandom $secureRandom, - $from, - $isDataEncrypted, + $defaultMailAddress, + IManager $encryptionManager, IMailer $mailer, ITimeFactory $timeFactory) { parent::__construct($appName, $request); @@ -103,8 +104,8 @@ class LostController extends Controller { $this->defaults = $defaults; $this->l10n = $l10n; $this->secureRandom = $secureRandom; - $this->from = $from; - $this->isDataEncrypted = $isDataEncrypted; + $this->from = $defaultMailAddress; + $this->encryptionManager = $encryptionManager; $this->config = $config; $this->mailer = $mailer; $this->timeFactory = $timeFactory; @@ -207,7 +208,7 @@ class LostController extends Controller { * @return array */ public function setPassword($token, $userId, $password, $proceed) { - if ($this->isDataEncrypted && !$proceed) { + if ($this->encryptionManager->isEnabled() && !$proceed) { return $this->error('', array('encryption' => true)); } diff --git a/core/Controller/TokenController.php b/core/Controller/TokenController.php index 6e3ff50fa1d..865bae9665c 100644 --- a/core/Controller/TokenController.php +++ b/core/Controller/TokenController.php @@ -27,14 +27,14 @@ use OC\AppFramework\Http; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager; -use OC\User\Manager as UserManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; +use OCP\IUserManager; use OCP\Security\ISecureRandom; class TokenController extends Controller { - /** @var UserManager */ + /** @var IUserManager */ private $userManager; /** @var IProvider */ private $tokenProvider; @@ -46,14 +46,14 @@ class TokenController extends Controller { /** * @param string $appName * @param IRequest $request - * @param UserManager $userManager + * @param IUserManager $userManager * @param IProvider $tokenProvider * @param TwoFactorAuthManager $twoFactorAuthManager * @param ISecureRandom $secureRandom */ public function __construct($appName, IRequest $request, - UserManager $userManager, + IUserManager $userManager, IProvider $tokenProvider, TwoFactorAuthManager $twoFactorAuthManager, ISecureRandom $secureRandom) { |