Skip to content

Commit 5907c00

Browse files
committed
fix: Add direct parameter to flow auth v2
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent bb1f27f commit 5907c00

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

core/Controller/ClientFlowLoginV2Controller.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ public function poll(string $token): JSONResponse {
8484
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
8585
#[UseSession]
8686
#[FrontpageRoute(verb: 'GET', url: '/login/v2/flow/{token}')]
87-
public function landing(string $token, $user = ''): Response {
87+
public function landing(string $token, $user = '', int $direct = 0): Response {
8888
if (!$this->loginFlowV2Service->startLoginFlow($token)) {
8989
return $this->loginTokenForbiddenResponse();
9090
}
9191

9292
$this->session->set(self::TOKEN_NAME, $token);
9393

9494
return new RedirectResponse(
95-
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user])
95+
$this->urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.showAuthPickerPage', ['user' => $user, 'direct' => $direct])
9696
);
9797
}
9898

@@ -103,7 +103,7 @@ public function landing(string $token, $user = ''): Response {
103103
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
104104
#[UseSession]
105105
#[FrontpageRoute(verb: 'GET', url: '/login/v2/flow')]
106-
public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
106+
public function showAuthPickerPage(string $user = '', int $direct = 0): StandaloneTemplateResponse {
107107
try {
108108
$flow = $this->getFlowByLoginToken();
109109
} catch (LoginFlowV2NotFoundException $e) {
@@ -125,6 +125,7 @@ public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
125125
'urlGenerator' => $this->urlGenerator,
126126
'stateToken' => $stateToken,
127127
'user' => $user,
128+
'direct' => $direct,
128129
],
129130
'guest'
130131
);
@@ -138,7 +139,7 @@ public function showAuthPickerPage($user = ''): StandaloneTemplateResponse {
138139
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
139140
#[UseSession]
140141
#[FrontpageRoute(verb: 'GET', url: '/login/v2/grant')]
141-
public function grantPage(?string $stateToken): StandaloneTemplateResponse {
142+
public function grantPage(?string $stateToken, int $direct = 0): StandaloneTemplateResponse {
142143
if ($stateToken === null) {
143144
return $this->stateTokenMissingResponse();
144145
}
@@ -165,6 +166,7 @@ public function grantPage(?string $stateToken): StandaloneTemplateResponse {
165166
'instanceName' => $this->defaults->getName(),
166167
'urlGenerator' => $this->urlGenerator,
167168
'stateToken' => $stateToken,
169+
'direct' => $direct,
168170
],
169171
'guest'
170172
);

core/templates/loginflowv2/authpicker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<br/>
3232

3333
<p id="redirect-link">
34-
<form id="login-form" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken'], 'user' => $_['user']])) ?>" method="get">
34+
<form id="login-form" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.grantPage', ['stateToken' => $_['stateToken'], 'user' => $_['user'], 'direct' => $_['direct'] ?? 0])) ?>" method="get">
3535
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Log in')) ?>" disabled>
3636
</form>
3737
</p>

core/templates/loginflowv2/grant.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLoginV2.generateAppPassword')) ?>">
3434
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
3535
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
36+
<?php if ($_['direct']) { ?>
37+
<input type="hidden" name="direct" value="1" />
38+
<?php } ?>
3639
<div id="submit-wrapper">
3740
<input type="submit" class="login primary icon-confirm-white" title="" value="<?php p($l->t('Grant access')); ?>" />
3841
</div>

0 commit comments

Comments
 (0)