]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix encryption + remembered login due to missing login hook 4892/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Tue, 16 May 2017 06:41:11 +0000 (08:41 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Tue, 16 May 2017 06:41:11 +0000 (08:41 +0200)
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>
lib/private/Server.php
lib/private/User/Session.php

index 9d54421e3e99b2010401f9c1b5184dfbf3912b38..ad658373c7b36e1aeff07f184fe4763cded38318 100644 (file)
@@ -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());
                        });
index ac0150ff611128e113e700abef5d2f0fe50531f4..f818666c374d95619a520bb34c9ef5035a3a031f 100644 (file)
@@ -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;
        }