Fix encryption + remembered login due to missing login hook

The encryption app relies on the post_login hook to initialize its keys.
Since we do not emit it on a remembered login, the keys were always un-
initialized and the user was asked to log out and in again.
This patch *translates* the postRememberedLogin hook to a post_login
hook.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-05-16 08:41:11 +02:00
parent e920e20284
commit 0a43c259c4
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
2 changed files with 11 additions and 1 deletions

View File

@ -361,6 +361,10 @@ class Server extends ServerContainer implements IServerContainer {
/** @var $user \OC\User\User */ /** @var $user \OC\User\User */
\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
}); });
$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
/** @var $user \OC\User\User */
\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
});
$userSession->listen('\OC\User', 'logout', function () { $userSession->listen('\OC\User', 'logout', function () {
\OC_Hook::emit('OC_User', 'logout', array()); \OC_Hook::emit('OC_User', 'logout', array());
}); });

View File

@ -792,7 +792,13 @@ class Session implements IUserSession, Emitter {
$this->setToken($token->getId()); $this->setToken($token->getId());
$this->lockdownManager->setToken($token); $this->lockdownManager->setToken($token);
$user->updateLastLoginTimestamp(); $user->updateLastLoginTimestamp();
$this->manager->emit('\OC\User', 'postRememberedLogin', [$user]); $password = null;
try {
$password = $this->tokenProvider->getPassword($token, $sessionId);
} catch (PasswordlessTokenException $ex) {
// Ignore
}
$this->manager->emit('\OC\User', 'postRememberedLogin', [$user, $password]);
return true; return true;
} }