Skip to content

Commit

Permalink
fix for: ‘autofill username’ that resulted in a WRONGUSERPASS
Browse files Browse the repository at this point in the history
  • Loading branch information
doedje committed Jun 19, 2024
1 parent 9bdc046 commit 45a9288
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions modules/core/src/Controller/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,37 @@ public function loginuserpass(Request $request): Response
}


/**
* This page shows a username/password/organization login form, and passes information from
* into the \SimpleSAML\Module\core\Auth\UserPassBase class, which is a generic class for
* username/password/organization authentication.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function loginuserpassorg(Request $request): Response
{
// Retrieve the authentication state
if (!$request->query->has('AuthState')) {
throw new Error\BadRequest('Missing AuthState parameter.');
}
$authStateId = $request->query->get('AuthState');
$this->authState::validateStateId($authStateId);

$state = $this->authState::loadState($authStateId, UserPassOrgBase::STAGEID);

/** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $source */
$source = $this->authSource::getById($state[UserPassOrgBase::AUTHID]);
if ($source === null) {
throw new BuiltinException(
'Could not find authentication source with id ' . $state[UserPassOrgBase::AUTHID],
);
}

return $this->handleLogin($request, $source, $state);
}


/**
* This method handles the generic part for both loginuserpass and loginuserpassorg
*
Expand Down Expand Up @@ -146,7 +177,7 @@ private function handleLogin(Request $request, UserPassBase|UserPassOrgBase $sou
}

if ($organizations === null || $organization !== '') {
if (!empty($username) || !empty($password)) {
if (!empty($password)) {
$cookies = [];
$httpUtils = new Utils\HTTP();
$sameSiteNone = $httpUtils->canSetSamesiteNone() ? Cookie::SAMESITE_NONE : null;
Expand Down Expand Up @@ -303,37 +334,6 @@ private function handleLogin(Request $request, UserPassBase|UserPassOrgBase $sou
}


/**
* This page shows a username/password/organization login form, and passes information from
* into the \SimpleSAML\Module\core\Auth\UserPassBase class, which is a generic class for
* username/password/organization authentication.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function loginuserpassorg(Request $request): Response
{
// Retrieve the authentication state
if (!$request->query->has('AuthState')) {
throw new Error\BadRequest('Missing AuthState parameter.');
}
$authStateId = $request->query->get('AuthState');
$this->authState::validateStateId($authStateId);

$state = $this->authState::loadState($authStateId, UserPassOrgBase::STAGEID);

/** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $source */
$source = $this->authSource::getById($state[UserPassOrgBase::AUTHID]);
if ($source === null) {
throw new BuiltinException(
'Could not find authentication source with id ' . $state[UserPassOrgBase::AUTHID],
);
}

return $this->handleLogin($request, $source, $state);
}


/**
* @param string $name The name for the cookie
* @param string $value The value for the cookie
Expand Down

0 comments on commit 45a9288

Please sign in to comment.