Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ public function tryLogin($user, $password, $redirect_url) {
$this->session->set('loginMessages', [
['invalidpassword'], []
]);
$args = [];
// Read current user and append if possible - we need to return the unmodified user otherwise we will leak the login name
$args = !is_null($user) ? ['user' => $originalUser] : [];
if (!is_null($user)) {
$args['user'] = $originalUser;
}
// keep the redirect url
if (!empty($redirect_url)) {
$args['redirect_url'] = $redirect_url;
}
return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
}
// TODO: remove password checks from above and let the user session handle failures
Expand Down
6 changes: 3 additions & 3 deletions tests/Core/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function testShowLoginFormForUserNamedNull() {
}

public function testLoginWithInvalidCredentials() {
$user = $this->createMock(IUser::class);
$user = 'unknown';
$password = 'secret';
$loginPageUrl = 'some url';

Expand All @@ -295,14 +295,14 @@ public function testLoginWithInvalidCredentials() {
->will($this->returnValue(false));
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->with('core.login.showLoginForm')
->with('core.login.showLoginForm', ['user' => $user, 'redirect_url' => '/foo'])
->will($this->returnValue($loginPageUrl));

$this->userSession->expects($this->never())
->method('createSessionToken');

$expected = new RedirectResponse($loginPageUrl);
$this->assertEquals($expected, $this->loginController->tryLogin($user, $password, ''));
$this->assertEquals($expected, $this->loginController->tryLogin($user, $password, '/foo'));
}

public function testLoginWithValidCredentials() {
Expand Down