From 0a43c259c46bb820d46b8732f431622ecf4f25b3 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 16 May 2017 08:41:11 +0200 Subject: [PATCH] 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 --- lib/private/Server.php | 4 ++++ lib/private/User/Session.php | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/private/Server.php b/lib/private/Server.php index 9d54421e3e9..ad658373c7b 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -361,6 +361,10 @@ class Server extends ServerContainer implements IServerContainer { /** @var $user \OC\User\User */ \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 () { \OC_Hook::emit('OC_User', 'logout', array()); }); diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index ac0150ff611..f818666c374 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -792,7 +792,13 @@ class Session implements IUserSession, Emitter { $this->setToken($token->getId()); $this->lockdownManager->setToken($token); $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; } -- 2.39.5