diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-01-02 11:57:05 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-01-11 19:20:11 +0100 |
commit | 21d3fe588396ebb3535a947ee4afd514aa24bd78 (patch) | |
tree | 7e1d61534c7e58ef00f607980e0b707afd284ad4 /lib | |
parent | 6f74ecd94a65485f9cd09434845f3c62e66fb9e5 (diff) | |
download | nextcloud-server-21d3fe588396ebb3535a947ee4afd514aa24bd78.tar.gz nextcloud-server-21d3fe588396ebb3535a947ee4afd514aa24bd78.zip |
do not hard-require the token provider
The provider might need DB access and therefore depenedency
resolution fails on the setup page where we cannot inject
the db implementation.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Authentication/LoginCredentials/Store.php | 16 | ||||
-rw-r--r-- | lib/private/Server.php | 8 |
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php index c50b7246f64..e44c88c7aea 100644 --- a/lib/private/Authentication/LoginCredentials/Store.php +++ b/lib/private/Authentication/LoginCredentials/Store.php @@ -40,21 +40,21 @@ class Store implements IStore { /** @var ISession */ private $session; - /** @var IProvider */ - private $tokenProvider; - /** @var ILogger */ private $logger; + /** @var IProvider|null */ + private $tokenProvider; + /** * @param ISession $session - * @param IProvider $tokenProvider * @param ILogger $logger + * @param IProvider $tokenProvider */ - public function __construct(ISession $session, IProvider $tokenProvider, ILogger $logger) { + public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { $this->session = $session; - $this->tokenProvider = $tokenProvider; $this->logger = $logger; + $this->tokenProvider = $tokenProvider; Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); } @@ -84,6 +84,10 @@ class Store implements IStore { * @throws CredentialsUnavailableException */ public function getLoginCredentials() { + if (is_null($this->tokenProvider)) { + throw new CredentialsUnavailableException(); + } + $trySession = false; try { $sessionId = $this->session->getId(); diff --git a/lib/private/Server.php b/lib/private/Server.php index 45ed9d5e3bc..903e05925ee 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -250,9 +250,13 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService(Store::class, function(Server $c) { $session = $c->getSession(); - $tokenProvider = $c->query('OC\Authentication\Token\DefaultTokenProvider'); + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); + } else { + $tokenProvider = null; + } $logger = $c->getLogger(); - return new Store($session, $tokenProvider, $logger); + return new Store($session, $logger, $tokenProvider); }); $this->registerAlias(IStore::class, Store::class); $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |