From 2f21eaaf47192fb6381eed183cbefb7e0d6ce01b Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Wed, 21 Dec 2016 09:51:21 +0100
Subject: [PATCH] Use login name to fix password confirm with ldap users

Signed-off-by: Joas Schilling <coding@schilljs.com>
---
 core/Controller/LoginController.php | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index b6add48ef61..3c81ed5242a 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -298,14 +298,10 @@ class LoginController extends Controller {
 		$currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress());
 		$this->throttler->sleepDelay($this->request->getRemoteAddress());
 
-		$user = $this->userSession->getUser();
-		if (!$user instanceof IUser) {
-			return new DataResponse([], Http::STATUS_UNAUTHORIZED);
-		}
-
-		$loginResult = $this->userManager->checkPassword($user->getUID(), $password);
+		$loginName = $this->userSession->getLoginName();
+		$loginResult = $this->userManager->checkPassword($loginName, $password);
 		if ($loginResult === false) {
-			$this->throttler->registerAttempt('sudo', $this->request->getRemoteAddress(), ['user' => $user->getUID()]);
+			$this->throttler->registerAttempt('sudo', $this->request->getRemoteAddress(), ['user' => $loginName]);
 			if ($currentDelay === 0) {
 				$this->throttler->sleepDelay($this->request->getRemoteAddress());
 			}
-- 
GitLab