Merge pull request #24729 from owncloud/try-token-login-first

try token login first
This commit is contained in:
Vincent Petry 2016-05-23 20:50:57 +02:00
commit 5a8af2f0be
1 changed files with 13 additions and 5 deletions

View File

@ -288,12 +288,20 @@ class Session implements IUserSession, Emitter {
*/
public function login($uid, $password) {
$this->session->regenerateId();
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
$user = $this->manager->checkPassword($uid, $password);
if ($user === false) {
if ($this->validateToken($password)) {
$user = $this->getUser();
if ($this->validateToken($password)) {
$user = $this->getUser();
// When logging in with token, the password must be decrypted first before passing to login hook
try {
$token = $this->tokenProvider->getToken($password);
$password = $this->tokenProvider->getPassword($token, $password);
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
} catch (InvalidTokenException $ex) {
// Invalid token, nothing to do
}
} else {
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
$user = $this->manager->checkPassword($uid, $password);
}
if ($user !== false) {
if (!is_null($user)) {