From 2c89962919fe45bf5a577ad94f3cc0d9bc84ba35 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 21 May 2014 18:03:37 +0200 Subject: [PATCH 01/12] clean up tryRememberLogin and save the timestamp of users last login --- lib/base.php | 24 +++++++++--------------- lib/private/user.php | 11 +++++++++++ lib/private/user/manager.php | 6 ++++++ lib/private/user/session.php | 32 ++++++++++++++++++++++++++++++++ lib/private/user/user.php | 27 +++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 15 deletions(-) diff --git a/lib/base.php b/lib/base.php index abb76b94a5..9441749f1d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -883,30 +883,24 @@ class OC { if (defined("DEBUG") && DEBUG) { OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG); } - // confirm credentials in cookie - if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) { - // delete outdated cookies + + if(OC_User::userExists($_COOKIE['oc_username'])) { self::cleanupLoginTokens($_COOKIE['oc_username']); - // get stored tokens - $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token'); - // test cookies token against stored tokens - if (in_array($_COOKIE['oc_token'], $tokens, true)) { - // replace successfully used token with a new one - OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']); - $token = OC_Util::generateRandomBytes(32); - OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time()); - OC_User::setMagicInCookie($_COOKIE['oc_username'], $token); - // login - OC_User::setUserId($_COOKIE['oc_username']); + // confirm credentials in cookie + $granted = OC_User::loginWithCookie( + $_COOKIE['oc_username'], $_COOKIE['oc_token']); + if($granted === true) { OC_Util::redirectToDefaultPage(); // doesn't return } + OC_Log::write('core', 'Authentication cookie rejected for user ' . + $_COOKIE['oc_username'], OC_Log::WARN); // if you reach this point you have changed your password // or you are an attacker // we can not delete tokens here because users may reach // this point multiple times after a password change - OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN); } + OC_User::unsetMagicInCookie(); return true; } diff --git a/lib/private/user.php b/lib/private/user.php index 9276d7923c..5d3ebb57c8 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -235,6 +235,17 @@ class OC_User { return self::getUserSession()->login($uid, $password); } + /** + * Try to login a user using the magic cookie (remember login) + * + * @param string $uid The username of the user to log in + * @param string $token + * @return bool + */ + public static function loginWithCookie($uid, $token) { + return self::getUserSession()->loginWithCookie($uid, $token); + } + /** * Try to login a user, assuming authentication * has already happened (e.g. via Single Sign On). diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 0fcf1ceb6a..914baebdf6 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -52,6 +52,12 @@ class Manager extends PublicEmitter { unset($cachedUsers[$i]); } }); + $this->listen('\OC\User', 'postLogin', function ($user, $pw) { + $user->updateLastLoginTimestamp(); + }); + $this->listen('\OC\User', 'postRememberedLogin', function ($user) { + $user->updateLastLoginTimestamp(); + }); } /** diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 3d10b134b8..91e203f044 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -170,6 +170,38 @@ class Session implements Emitter, \OCP\IUserSession { } } + /** + * perform login using the magic cookie (remember login) + * + * @param string $uid the username + * @param string $currentToken + * @return bool + */ + public function loginWithCookie($uid, $currentToken) { + $user = $this->manager->get($uid); + if(is_null($user)) { + // user does not exist + return false; + } + + // get stored tokens + $tokens = \OC_Preferences::getKeys($uid, 'login_token'); + // test cookies token against stored tokens + if(!in_array($currentToken, $tokens, true)) { + return false; + } + // replace successfully used token with a new one + \OC_Preferences::deleteKey($uid, 'login_token', $currentToken); + $newToken = \OC_Util::generateRandomBytes(32); + \OC_Preferences::setValue($uid, 'login_token', $newToken, time()); + $this->setMagicInCookie($user->getUID(), $newToken); + + //login + $this->setUser($user); + $this->manager->emit('\OC\User', 'postRememberedLogin', array($user)); + return true; + } + /** * logout the user from the session */ diff --git a/lib/private/user/user.php b/lib/private/user/user.php index bc5c541e52..e059881364 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -42,6 +42,11 @@ class User { */ private $home; + /** + * @var int $lastLogin + */ + private $lastLogin; + /** * @var \OC\AllConfig $config */ @@ -64,6 +69,7 @@ class User { } else { $this->enabled = true; } + $this->lastLogin = \OC_Preferences::getValue($uid, 'login', 'lastLogin', 0); } /** @@ -107,6 +113,27 @@ class User { } } + /** + * returns the timestamp of the user's last login or 0 if the user did never + * login + * + * @return int + */ + public function getLastLogin() { + return $this->lastLogin; + } + + /** + * updates the timestamp of the most recent login of this user + * + * @return null + */ + public function updateLastLoginTimestamp() { + $this->lastLogin = time(); + \OC_Preferences::setValue( + $this->uid, 'login', 'lastLogin', $this->lastLogin); + } + /** * Delete the user * From c46fada6b3338b045d3104f71e4e43558eca5453 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 00:18:07 +0200 Subject: [PATCH 02/12] unit tests for loginWithCookie() --- tests/lib/user/session.php | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 46b268b362..7b9d24103d 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -151,4 +151,118 @@ class Session extends \PHPUnit_Framework_TestCase { $userSession = new \OC\User\Session($manager, $session); $userSession->login('foo', 'bar'); } + + public function testRememberLoginValidToken() { + $session = $this->getMock('\OC\Session\Memory', array(), array('')); + $session->expects($this->exactly(1)) + ->method('set') + ->with($this->callback(function($key) { + switch($key) { + case 'user_id': + return true; + break; + default: + return false; + break; + } + }, + 'foo')); + + $manager = $this->getMock('\OC\User\Manager'); + + $backend = $this->getMock('OC_User_Dummy'); + + $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); + + $user->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('foo')); + + $manager->expects($this->once()) + ->method('get') + ->with('foo') + ->will($this->returnValue($user)); + + //prepare login token + $token = 'goodToken'; + \OC_Preferences::setValue('foo', 'login_token', $token, time()); + + $userSession = $this->getMock( + '\OC\User\Session', + //override, otherwise tests will fail because of setcookie() + array('setMagicInCookie'), + //there are passed as parameters to the constructor + array($manager, $session)); + + $granted = $userSession->loginWithCookie('foo', $token); + //clean up token + \OC_Preferences::deleteKey('foo', 'login_token', $token); + + $this->assertSame($granted, true); + } + + public function testRememberLoginInvalidToken() { + $session = $this->getMock('\OC\Session\Memory', array(), array('')); + $session->expects($this->never()) + ->method('set'); + + $manager = $this->getMock('\OC\User\Manager'); + + $backend = $this->getMock('OC_User_Dummy'); + + $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); + + $user->expects($this->any()) + ->method('getUID') + ->will($this->returnValue('foo')); + + $manager->expects($this->once()) + ->method('get') + ->with('foo') + ->will($this->returnValue($user)); + + //prepare login token + $token = 'goodToken'; + \OC_Preferences::setValue('foo', 'login_token', $token, time()); + + $userSession = new \OC\User\Session($manager, $session); + $granted = $userSession->loginWithCookie('foo', 'badToken'); + //clean up token + \OC_Preferences::deleteKey('foo', 'login_token', $token); + + $this->assertSame($granted, false); + } + + public function testRememberLoginInvalidUser() { + $session = $this->getMock('\OC\Session\Memory', array(), array('')); + $session->expects($this->never()) + ->method('set'); + + $manager = $this->getMock('\OC\User\Manager'); + + $backend = $this->getMock('OC_User_Dummy'); + + $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); + + $user->expects($this->never()) + ->method('getUID'); + + $manager->expects($this->once()) + ->method('get') + ->with('foo') + ->will($this->returnValue(null)); + + //prepare login token + $token = 'goodToken'; + \OC_Preferences::setValue('foo', 'login_token', $token, time()); + + $userSession = new \OC\User\Session($manager, $session); + $granted = $userSession->loginWithCookie('foo', $token); + //clean up token + \OC_Preferences::deleteKey('foo', 'login_token', $token); + + $this->assertSame($granted, false); + + + } } From bf1f5f2af3958863e0fb2e873e4b4c6dcb260f46 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 00:54:17 +0200 Subject: [PATCH 03/12] also test whether hooks work --- tests/lib/user/session.php | 44 +++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 7b9d24103d..447b3a6619 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -168,7 +168,17 @@ class Session extends \PHPUnit_Framework_TestCase { }, 'foo')); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); @@ -177,6 +187,8 @@ class Session extends \PHPUnit_Framework_TestCase { $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('foo')); + $user->expects($this->once()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('get') @@ -206,7 +218,17 @@ class Session extends \PHPUnit_Framework_TestCase { $session->expects($this->never()) ->method('set'); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); @@ -215,6 +237,8 @@ class Session extends \PHPUnit_Framework_TestCase { $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('foo')); + $user->expects($this->never()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('get') @@ -238,7 +262,17 @@ class Session extends \PHPUnit_Framework_TestCase { $session->expects($this->never()) ->method('set'); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); @@ -246,6 +280,8 @@ class Session extends \PHPUnit_Framework_TestCase { $user->expects($this->never()) ->method('getUID'); + $user->expects($this->never()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('get') @@ -262,7 +298,5 @@ class Session extends \PHPUnit_Framework_TestCase { \OC_Preferences::deleteKey('foo', 'login_token', $token); $this->assertSame($granted, false); - - } } From 60274d17294dc4fb2c9de151f478790d0177d6ca Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 00:59:26 +0200 Subject: [PATCH 04/12] test hooks also on login --- tests/lib/user/session.php | 42 +++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 447b3a6619..5c58d82f5b 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -67,7 +67,17 @@ class Session extends \PHPUnit_Framework_TestCase { }, 'foo')); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); @@ -78,6 +88,8 @@ class Session extends \PHPUnit_Framework_TestCase { $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('foo')); + $user->expects($this->once()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPassword') @@ -94,7 +106,17 @@ class Session extends \PHPUnit_Framework_TestCase { $session->expects($this->never()) ->method('set'); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); @@ -102,6 +124,8 @@ class Session extends \PHPUnit_Framework_TestCase { $user->expects($this->once()) ->method('isEnabled') ->will($this->returnValue(false)); + $user->expects($this->never()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPassword') @@ -117,13 +141,25 @@ class Session extends \PHPUnit_Framework_TestCase { $session->expects($this->never()) ->method('set'); - $manager = $this->getMock('\OC\User\Manager'); + $managerMethods = get_class_methods('\OC\User\Manager'); + //keep following methods intact in order to ensure hooks are + //working + $doNotMock = array('__construct', 'emit', 'listen'); + foreach($doNotMock as $methodName) { + $i = array_search($methodName, $managerMethods, true); + if($i !== false) { + unset($managerMethods[$i]); + } + } + $manager = $this->getMock('\OC\User\Manager', $managerMethods, array()); $backend = $this->getMock('OC_User_Dummy'); $user = $this->getMock('\OC\User\User', array(), array('foo', $backend)); $user->expects($this->never()) ->method('isEnabled'); + $user->expects($this->never()) + ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPassword') From 86880acee9a5a4887884f6095ecfe90e32e1e5d3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 10:16:18 +0200 Subject: [PATCH 05/12] clean up here is superflous, will already be removed by user session --- tests/lib/user/session.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 5c58d82f5b..3f9d43e295 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -243,8 +243,6 @@ class Session extends \PHPUnit_Framework_TestCase { array($manager, $session)); $granted = $userSession->loginWithCookie('foo', $token); - //clean up token - \OC_Preferences::deleteKey('foo', 'login_token', $token); $this->assertSame($granted, true); } @@ -287,8 +285,6 @@ class Session extends \PHPUnit_Framework_TestCase { $userSession = new \OC\User\Session($manager, $session); $granted = $userSession->loginWithCookie('foo', 'badToken'); - //clean up token - \OC_Preferences::deleteKey('foo', 'login_token', $token); $this->assertSame($granted, false); } @@ -330,8 +326,6 @@ class Session extends \PHPUnit_Framework_TestCase { $userSession = new \OC\User\Session($manager, $session); $granted = $userSession->loginWithCookie('foo', $token); - //clean up token - \OC_Preferences::deleteKey('foo', 'login_token', $token); $this->assertSame($granted, false); } From 09bb8e0e3a9ba2213f3c2bd9774bbfb1502b7be5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 10:37:34 +0200 Subject: [PATCH 06/12] add cli command to check a users last login --- core/command/user/lastseen.php | 47 ++++++++++++++++++++++++++++++++++ core/register_command.php | 1 + 2 files changed, 48 insertions(+) create mode 100644 core/command/user/lastseen.php diff --git a/core/command/user/lastseen.php b/core/command/user/lastseen.php new file mode 100644 index 0000000000..bf5914b2cd --- /dev/null +++ b/core/command/user/lastseen.php @@ -0,0 +1,47 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Core\Command\User; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; + +class LastSeen extends Command { + protected function configure() { + $this + ->setName('user:lastseen') + ->setDescription('shows when the user was logged it last time') + ->addArgument( + 'uid', + InputArgument::REQUIRED, + 'the username' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $userManager = \OC::$server->getUserManager(); + $user = $userManager->get($input->getArgument('uid')); + if(is_null($user)) { + $output->writeln('User does not exist'); + return; + } + + $lastLogin = $user->getLastLogin(); + if($lastLogin === 0) { + $output->writeln('User ' . $user->getUID() . + ' has never logged in, yet.'); + } else { + $date = new \DateTime(); + $date->setTimestamp($lastLogin); + $output->writeln($user->getUID() . '`s ' . + ' last login: ' . $date->format('d.m.Y h:i')); + } + } +} diff --git a/core/register_command.php b/core/register_command.php index f1361c859f..dfb5134eff 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -17,3 +17,4 @@ $application->add(new OC\Core\Command\App\Enable()); $application->add(new OC\Core\Command\App\ListApps()); $application->add(new OC\Core\Command\Maintenance\Repair(new \OC\Repair())); $application->add(new OC\Core\Command\User\Report()); +$application->add(new OC\Core\Command\User\LastSeen()); From e9fa74bfb791796ec53b1129c3e20cdcccc9aa49 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 10:55:54 +0200 Subject: [PATCH 07/12] save a whitespace --- core/command/user/lastseen.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/command/user/lastseen.php b/core/command/user/lastseen.php index bf5914b2cd..b2788c0030 100644 --- a/core/command/user/lastseen.php +++ b/core/command/user/lastseen.php @@ -40,8 +40,8 @@ class LastSeen extends Command { } else { $date = new \DateTime(); $date->setTimestamp($lastLogin); - $output->writeln($user->getUID() . '`s ' . - ' last login: ' . $date->format('d.m.Y h:i')); + $output->writeln($user->getUID() . + '`s last login: ' . $date->format('d.m.Y h:i')); } } } From 2e85d5a852aeda82a470c8cdc55ff143fdc570e5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 11:20:46 +0200 Subject: [PATCH 08/12] increase scrutinizer happyiness by removing minor/informational issues --- lib/private/user/manager.php | 2 +- tests/lib/user/session.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 914baebdf6..f2964fecca 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -52,7 +52,7 @@ class Manager extends PublicEmitter { unset($cachedUsers[$i]); } }); - $this->listen('\OC\User', 'postLogin', function ($user, $pw) { + $this->listen('\OC\User', 'postLogin', function ($user) { $user->updateLastLoginTimestamp(); }); $this->listen('\OC\User', 'postRememberedLogin', function ($user) { diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php index 3f9d43e295..2845a9c964 100644 --- a/tests/lib/user/session.php +++ b/tests/lib/user/session.php @@ -196,10 +196,8 @@ class Session extends \PHPUnit_Framework_TestCase { switch($key) { case 'user_id': return true; - break; default: return false; - break; } }, 'foo')); From 7f7999c7d870c1024246cd49917554513cbab76b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 23 May 2014 19:12:51 +0200 Subject: [PATCH 09/12] print time in 24h format --- core/command/user/lastseen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/command/user/lastseen.php b/core/command/user/lastseen.php index b2788c0030..7a8db013e3 100644 --- a/core/command/user/lastseen.php +++ b/core/command/user/lastseen.php @@ -41,7 +41,7 @@ class LastSeen extends Command { $date = new \DateTime(); $date->setTimestamp($lastLogin); $output->writeln($user->getUID() . - '`s last login: ' . $date->format('d.m.Y h:i')); + '`s last login: ' . $date->format('d.m.Y H:i')); } } } From c03e7fcfa9419a31cc6d92d40c55532dab9578f3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 24 May 2014 10:24:42 +0200 Subject: [PATCH 10/12] Clarify comment --- lib/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index 9441749f1d..6206ebebe9 100644 --- a/lib/base.php +++ b/lib/base.php @@ -886,7 +886,7 @@ class OC { if(OC_User::userExists($_COOKIE['oc_username'])) { self::cleanupLoginTokens($_COOKIE['oc_username']); - // confirm credentials in cookie + // verify whether the supplied "remember me" token was valid $granted = OC_User::loginWithCookie( $_COOKIE['oc_username'], $_COOKIE['oc_token']); if($granted === true) { From 748a2192434918324a4cd42b855fb77d8769680a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 26 May 2014 13:53:26 +0200 Subject: [PATCH 11/12] add preRememberedLogin hook and document this and postRememberedLogin in class descripttion. Also fixes documentation of postLogin hook --- lib/private/user/session.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 91e203f044..5f0dee607a 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -22,7 +22,9 @@ use OC\Hooks\Emitter; * - preCreateUser(string $uid, string $password) * - postCreateUser(\OC\User\User $user) * - preLogin(string $user, string $password) - * - postLogin(\OC\User\User $user) + * - postLogin(\OC\User\User $user, string $password) + * - preRememberedLogin(string $uid) + * - postRememberedLogin(\OC\User\User $user) * - logout() * * @package OC\User @@ -178,6 +180,7 @@ class Session implements Emitter, \OCP\IUserSession { * @return bool */ public function loginWithCookie($uid, $currentToken) { + $this->manager->emit('\OC\User', 'preRememberedLogin', array($uid)); $user = $this->manager->get($uid); if(is_null($user)) { // user does not exist From 4a4ea67a31cda773dc84fb1fd617bfc27f77d5b8 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 26 May 2014 13:56:08 +0200 Subject: [PATCH 12/12] drop superflous statement in phpdoc --- lib/private/user/user.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/private/user/user.php b/lib/private/user/user.php index e059881364..8aba7188e2 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -125,8 +125,6 @@ class User { /** * updates the timestamp of the most recent login of this user - * - * @return null */ public function updateLastLoginTimestamp() { $this->lastLogin = time();