Merge pull request #29530 from nextcloud/bugfix/noid/username-prefill

This commit is contained in:
Julius Härtl 2021-12-29 14:58:35 +01:00 committed by GitHub
commit a37909f61c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 18 additions and 11 deletions

View file

@ -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'
);

View file

@ -100,7 +100,7 @@ class ClientFlowLoginV2Controller extends Controller {
* @PublicPage
* @UseSession
*/
public function landing(string $token): Response {
public function landing(string $token, $user = ''): Response {
if (!$this->loginFlowV2Service->startLoginFlow($token)) {
return $this->loginTokenForbiddenResponse();
}
@ -108,7 +108,7 @@ class ClientFlowLoginV2Controller extends Controller {
$this->session->set(self::TOKEN_NAME, $token);
return new RedirectResponse(
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage')
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user])
);
}
@ -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'
);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -143,7 +143,7 @@ export default {
data() {
return {
loading: false,
user: this.username,
user: loadState('core', 'loginUsername', ''),
passwordlessLogin: false,
resetPassword: false,
@ -151,7 +151,6 @@ export default {
errors: loadState('core', 'loginErrors', []),
messages: loadState('core', 'loginMessages', []),
redirectUrl: loadState('core', 'loginRedirectUrl', false),
username: loadState('core', 'loginUsername', ''),
throttleDelay: loadState('core', 'loginThrottleDelay', 0),
invertedColors: OCA.Theming && OCA.Theming.inverted,
canResetPassword: loadState('core', 'loginCanResetPassword', false),

View file

@ -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>

View file

@ -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>

View file

@ -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 {

View file

@ -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'
);