summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-01-23 22:12:51 +0100
committerGitHub <noreply@github.com>2019-01-23 22:12:51 +0100
commit425edf88d781b39565ff8f7ac160459e1b1efb40 (patch)
treec03271af7cecc1ee406ac4cb8c83ea3e2659d845
parent31335f983c87a712b76d9b09c51be347e9cddb15 (diff)
parentad5a658e0cf973d608f453444b0bfabb2293d06d (diff)
downloadnextcloud-server-425edf88d781b39565ff8f7ac160459e1b1efb40.tar.gz
nextcloud-server-425edf88d781b39565ff8f7ac160459e1b1efb40.zip
Merge pull request #13770 from nextcloud/enhancement/post-login-hook-is-token
Add isTokenLogin argument to post login hook/event
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/private/User/Session.php9
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 03d115fe022..5a8aad4107c 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -413,9 +413,9 @@ class Server extends ServerContainer implements IServerContainer {
$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
});
- $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
+ $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
/** @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, 'isTokenLogin' => $isTokenLogin));
});
$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
/** @var $user \OC\User\User */
diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php
index a69aed3910b..45f9cbc260f 100644
--- a/lib/private/User/Session.php
+++ b/lib/private/User/Session.php
@@ -360,7 +360,8 @@ class Session implements IUserSession, Emitter {
$this->setUser($user);
$this->setLoginName($loginDetails['loginName']);
- if(isset($loginDetails['token']) && $loginDetails['token'] instanceof IToken) {
+ $isToken = isset($loginDetails['token']) && $loginDetails['token'] instanceof IToken;
+ if ($isToken) {
$this->setToken($loginDetails['token']->getId());
$this->lockdownManager->setToken($loginDetails['token']);
$firstTimeLogin = false;
@@ -368,7 +369,11 @@ class Session implements IUserSession, Emitter {
$this->setToken(null);
$firstTimeLogin = $user->updateLastLoginTimestamp();
}
- $this->manager->emit('\OC\User', 'postLogin', [$user, $loginDetails['password']]);
+ $this->manager->emit('\OC\User', 'postLogin', [
+ $user,
+ $loginDetails['password'],
+ $isToken,
+ ]);
if($this->isLoggedIn()) {
$this->prepareUserLogin($firstTimeLogin, $regenerateSessionId);
return true;