don't regenerate Session ID twice, also fixes tests

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2016-12-02 11:16:33 +01:00
parent 50844e8c47
commit daf9d23547
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 7 additions and 4 deletions

View File

@ -328,10 +328,11 @@ class Session implements IUserSession, Emitter {
/**
* @param IUser $user
* @param array $loginDetails
* @param bool $regenerateSessionId
* @return bool
* @throws LoginException
*/
public function completeLogin(IUser $user, array $loginDetails) {
public function completeLogin(IUser $user, array $loginDetails, $regenerateSessionId = true) {
if (!$user->isEnabled()) {
// disabled users can not log in
// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
@ -339,7 +340,9 @@ class Session implements IUserSession, Emitter {
throw new LoginException($message);
}
$this->session->regenerateId();
if($regenerateSessionId) {
$this->session->regenerateId();
}
$this->setUser($user);
$this->setLoginName($loginDetails['loginName']);
@ -536,7 +539,7 @@ class Session implements IUserSession, Emitter {
return false;
}
return $this->completeLogin($user, ['loginName' => $uid, 'password' => $password]);
return $this->completeLogin($user, ['loginName' => $uid, 'password' => $password], false);
}
/**
@ -570,7 +573,7 @@ class Session implements IUserSession, Emitter {
return false;
}
return $this->completeLogin($user, ['loginName' => $uid, 'password' => $password, 'token' => $dbToken]);
return $this->completeLogin($user, ['loginName' => $uid, 'password' => $password, 'token' => $dbToken], false);
}
/**