summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-02-10 16:00:47 -0600
committerGitHub <noreply@github.com>2017-02-10 16:00:47 -0600
commitdfaaebd76551b81da7bc59ed75b4514be2e10dac (patch)
treee6429cce1ad9f174893cf68c3cb3eec5dff95205
parentabf0606054c2f17b8afe90994fd39f67ff959c6f (diff)
parentefdc51c155c71ca65ba3f41f36a8a6961480b7e6 (diff)
downloadnextcloud-server-dfaaebd76551b81da7bc59ed75b4514be2e10dac.tar.gz
nextcloud-server-dfaaebd76551b81da7bc59ed75b4514be2e10dac.zip
Merge pull request #3417 from nextcloud/push-notification
Push notification
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php7
-rw-r--r--lib/private/User/Session.php22
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index 0879b3e9330..5a350bbec5a 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -342,6 +342,13 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $c->query(Validator::class);
});
+ $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
+ return new \OC\Security\IdentityProof\Manager(
+ $this->getServer()->getAppDataDir('identityproof'),
+ $this->getServer()->getCrypto()
+ );
+ });
+
/**
* App Framework APIs
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php
index 9cc42e671a8..705ca95210a 100644
--- a/lib/private/User/Session.php
+++ b/lib/private/User/Session.php
@@ -284,6 +284,19 @@ class Session implements IUserSession, Emitter {
}
/**
+ * set the token id
+ *
+ * @param int|null $token that was used to log in
+ */
+ protected function setToken($token) {
+ if ($token === null) {
+ $this->session->remove('token-id');
+ } else {
+ $this->session->set('token-id', $token);
+ }
+ }
+
+ /**
* try to log in with the provided credentials
*
* @param string $uid
@@ -473,6 +486,7 @@ class Session implements IUserSession, Emitter {
if ($user->isEnabled()) {
$this->setUser($user);
$this->setLoginName($uid);
+ $this->setToken(null);
$firstTimeLogin = $user->updateLastLoginTimestamp();
$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
if ($this->isLoggedIn()) {
@@ -495,7 +509,7 @@ class Session implements IUserSession, Emitter {
*
* @param string $token
* @return boolean
- * @throws LoginException if an app canceld the login process or the user is not enabled
+ * @throws LoginException if an app canceled the login process or the user is not enabled
*/
private function loginWithToken($token) {
try {
@@ -530,6 +544,7 @@ class Session implements IUserSession, Emitter {
//login
$this->setUser($user);
$this->setLoginName($dbToken->getLoginName());
+ $this->setToken($dbToken->getId());
\OC::$server->getLockdownManager()->setToken($dbToken);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
@@ -740,10 +755,12 @@ class Session implements IUserSession, Emitter {
}
$this->setMagicInCookie($user->getUID(), $newToken);
+ $token = $this->tokenProvider->getToken($sessionId);
//login
$this->setUser($user);
- $this->setLoginName($this->tokenProvider->getToken($sessionId)->getLoginName());
+ $this->setLoginName($token->getLoginName());
+ $this->setToken($token->getId());
$user->updateLastLoginTimestamp();
$this->manager->emit('\OC\User', 'postRememberedLogin', [$user]);
return true;
@@ -773,6 +790,7 @@ class Session implements IUserSession, Emitter {
}
$this->setUser(null);
$this->setLoginName(null);
+ $this->setToken(null);
$this->unsetMagicInCookie();
$this->session->clear();
}