mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Pass username prefill through unauthenticated request redirects
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
8eab1fedfe
commit
61dd1d3d97
6 changed files with 12 additions and 4 deletions
|
|
@ -167,7 +167,7 @@ class ClientFlowLoginController extends Controller {
|
|||
*
|
||||
* @return StandaloneTemplateResponse
|
||||
*/
|
||||
public function showAuthPickerPage($clientIdentifier = '') {
|
||||
public function showAuthPickerPage($clientIdentifier = '', $user = '') {
|
||||
$clientName = $this->getClientName();
|
||||
$client = null;
|
||||
if ($clientIdentifier !== '') {
|
||||
|
|
@ -218,6 +218,7 @@ class ClientFlowLoginController extends Controller {
|
|||
'stateToken' => $stateToken,
|
||||
'serverHost' => $this->getServerPath(),
|
||||
'oauthState' => $this->session->get('oauth.state'),
|
||||
'user' => $user,
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class ClientFlowLoginV2Controller extends Controller {
|
|||
* @PublicPage
|
||||
* @UseSession
|
||||
*/
|
||||
public function showAuthPickerPage(): StandaloneTemplateResponse {
|
||||
public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
|
||||
try {
|
||||
$flow = $this->getFlowByLoginToken();
|
||||
} catch (LoginFlowV2NotFoundException $e) {
|
||||
|
|
@ -138,6 +138,7 @@ class ClientFlowLoginV2Controller extends Controller {
|
|||
'instanceName' => $this->defaults->getName(),
|
||||
'urlGenerator' => $this->urlGenerator,
|
||||
'stateToken' => $stateToken,
|
||||
'user' => $user,
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ $urlGenerator = $_['urlGenerator'];
|
|||
<br/>
|
||||
|
||||
<p id="redirect-link">
|
||||
<a href="<?php p($urlGenerator->linkToRoute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState']])) ?>">
|
||||
<a href="<?php p($urlGenerator->linkToRoute('core.ClientFlowLogin.grantPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState'], 'user' => $_['user']])) ?>">
|
||||
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>">
|
||||
</a>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ $urlGenerator = $_['urlGenerator'];
|
|||
<br/>
|
||||
|
||||
<p id="redirect-link">
|
||||
<a href="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken']])) ?>">
|
||||
<a href="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken'], 'user' => $_['user']])) ?>">
|
||||
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>">
|
||||
</a>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -260,6 +260,10 @@ class SecurityMiddleware extends Middleware {
|
|||
if (isset($this->request->server['REQUEST_URI'])) {
|
||||
$params['redirect_url'] = $this->request->server['REQUEST_URI'];
|
||||
}
|
||||
$usernamePrefill = $this->request->getParam('user', '');
|
||||
if ($usernamePrefill !== '') {
|
||||
$params['user'] = $usernamePrefill;
|
||||
}
|
||||
$url = $this->urlGenerator->linkToRoute('core.login.showLoginForm', $params);
|
||||
$response = new RedirectResponse($url);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
'stateToken' => 'StateToken',
|
||||
'serverHost' => 'https://example.com',
|
||||
'oauthState' => 'OauthStateToken',
|
||||
'user' => '',
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
|
|
@ -246,6 +247,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
'stateToken' => 'StateToken',
|
||||
'serverHost' => 'https://example.com',
|
||||
'oauthState' => 'OauthStateToken',
|
||||
'user' => '',
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue