try token login first

This commit is contained in:
Christoph Wurst 2016-05-19 15:52:38 +02:00
parent f42cdec4c4
commit 11dc97da43
No known key found for this signature in database
GPG Key ID: FEECD2543CA6EAF0
1 changed files with 13 additions and 5 deletions

View File

@ -287,12 +287,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)) {