Merge pull request #3417 from nextcloud/push-notification

Push notification
This commit is contained in:
Morris Jobke 2017-02-10 16:00:47 -06:00 committed by GitHub
commit dfaaebd765
2 changed files with 27 additions and 2 deletions

View File

@ -342,6 +342,13 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $c->query(Validator::class); 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 * App Framework APIs

View File

@ -283,6 +283,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 * try to log in with the provided credentials
* *
@ -473,6 +486,7 @@ class Session implements IUserSession, Emitter {
if ($user->isEnabled()) { if ($user->isEnabled()) {
$this->setUser($user); $this->setUser($user);
$this->setLoginName($uid); $this->setLoginName($uid);
$this->setToken(null);
$firstTimeLogin = $user->updateLastLoginTimestamp(); $firstTimeLogin = $user->updateLastLoginTimestamp();
$this->manager->emit('\OC\User', 'postLogin', [$user, $password]); $this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
@ -495,7 +509,7 @@ class Session implements IUserSession, Emitter {
* *
* @param string $token * @param string $token
* @return boolean * @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) { private function loginWithToken($token) {
try { try {
@ -530,6 +544,7 @@ class Session implements IUserSession, Emitter {
//login //login
$this->setUser($user); $this->setUser($user);
$this->setLoginName($dbToken->getLoginName()); $this->setLoginName($dbToken->getLoginName());
$this->setToken($dbToken->getId());
\OC::$server->getLockdownManager()->setToken($dbToken); \OC::$server->getLockdownManager()->setToken($dbToken);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password)); $this->manager->emit('\OC\User', 'postLogin', array($user, $password));
@ -740,10 +755,12 @@ class Session implements IUserSession, Emitter {
} }
$this->setMagicInCookie($user->getUID(), $newToken); $this->setMagicInCookie($user->getUID(), $newToken);
$token = $this->tokenProvider->getToken($sessionId);
//login //login
$this->setUser($user); $this->setUser($user);
$this->setLoginName($this->tokenProvider->getToken($sessionId)->getLoginName()); $this->setLoginName($token->getLoginName());
$this->setToken($token->getId());
$user->updateLastLoginTimestamp(); $user->updateLastLoginTimestamp();
$this->manager->emit('\OC\User', 'postRememberedLogin', [$user]); $this->manager->emit('\OC\User', 'postRememberedLogin', [$user]);
return true; return true;
@ -773,6 +790,7 @@ class Session implements IUserSession, Emitter {
} }
$this->setUser(null); $this->setUser(null);
$this->setLoginName(null); $this->setLoginName(null);
$this->setToken(null);
$this->unsetMagicInCookie(); $this->unsetMagicInCookie();
$this->session->clear(); $this->session->clear();
} }