Skip to content

Commit 3cd1463

Browse files
authored
Merge pull request #12723 from nextcloud/backport/12710/stable15
[stable15] Remove old button to submit the apppassword login
2 parents 160f013 + 6c14b57 commit 3cd1463

File tree

7 files changed

+20
-139
lines changed

7 files changed

+20
-139
lines changed

core/Controller/ClientFlowLoginController.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -242,34 +242,6 @@ public function grantPage($stateToken = '',
242242
);
243243
}
244244

245-
/**
246-
* @NoAdminRequired
247-
* @NoCSRFRequired
248-
* @UseSession
249-
*
250-
* @param string $stateToken
251-
* @param string $clientIdentifier
252-
* @return TemplateResponse
253-
*/
254-
public function redirectPage($stateToken = '',
255-
$clientIdentifier = '') {
256-
if(!$this->isValidToken($stateToken)) {
257-
return $this->stateTokenForbiddenResponse();
258-
}
259-
260-
return new TemplateResponse(
261-
$this->appName,
262-
'loginflow/redirect',
263-
[
264-
'urlGenerator' => $this->urlGenerator,
265-
'stateToken' => $stateToken,
266-
'clientIdentifier' => $clientIdentifier,
267-
'oauthState' => $this->session->get('oauth.state'),
268-
],
269-
'guest'
270-
);
271-
}
272-
273245
/**
274246
* @NoAdminRequired
275247
* @UseSession

core/js/login/grant.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
jQuery(document).ready(function() {
2+
$('#submit').click(function (e) {
3+
$('#submit + .submit-icon')
4+
.removeClass('icon-confirm-white')
5+
.addClass(OCA.Theming && OCA.Theming.inverted
6+
? 'icon-loading-small'
7+
: 'icon-loading-small-dark');
8+
})
9+
})

core/js/login/redirect.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

core/routes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
5353
['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
5454
['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
55-
['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
5655
['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
5756
['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
5857
['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],

core/templates/loginflow/grant.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*/
2121

22-
script('core', 'login/authpicker');
22+
script('core', 'login/grant');
2323
style('core', 'login/authpicker');
2424

2525
/** @var array $_ */
@@ -39,8 +39,15 @@
3939
<br/>
4040

4141
<p id="redirect-link">
42-
<a href="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.redirectPage', ['stateToken' => $_['stateToken'], 'clientIdentifier' => $_['clientIdentifier'], 'oauthState' => $_['oauthState']])) ?>">
43-
<input type="submit" class="login primary icon-confirm-white" value="<?php p($l->t('Grant access')) ?>">
44-
</a>
42+
<form method="POST" action="<?php p($urlGenerator->linkToRouteAbsolute('core.ClientFlowLogin.generateAppPassword')) ?>">
43+
<input type="hidden" name="clientIdentifier" value="<?php p($_['clientIdentifier']) ?>" />
44+
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
45+
<input type="hidden" name="stateToken" value="<?php p($_['stateToken']) ?>" />
46+
<input type="hidden" name="oauthState" value="<?php p($_['oauthState']) ?>" />
47+
<div id="submit-wrapper">
48+
<input type="submit" id="submit" class="login primary" title="" value="<?php p($l->t('Grant access')); ?>" />
49+
<div class="submit-icon icon-confirm-white"></div>
50+
</div>
51+
</form>
4552
</p>
4653
</div>

core/templates/loginflow/redirect.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/Core/Controller/ClientFlowLoginControllerTest.php

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -242,70 +242,6 @@ public function testShowAuthPickerPageWithOauth() {
242242
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage('MyClientIdentifier'));
243243
}
244244

245-
public function testRedirectPageWithInvalidToken() {
246-
$this->session
247-
->expects($this->once())
248-
->method('get')
249-
->with('client.flow.state.token')
250-
->willReturn('OtherToken');
251-
252-
$expected = new TemplateResponse(
253-
'core',
254-
'403',
255-
[
256-
'file' => 'State token does not match',
257-
],
258-
'guest'
259-
);
260-
$expected->setStatus(Http::STATUS_FORBIDDEN);
261-
$this->assertEquals($expected, $this->clientFlowLoginController->redirectPage('MyStateToken'));
262-
}
263-
264-
public function testRedirectPageWithoutToken() {
265-
$this->session
266-
->expects($this->once())
267-
->method('get')
268-
->with('client.flow.state.token')
269-
->willReturn(null);
270-
271-
$expected = new TemplateResponse(
272-
'core',
273-
'403',
274-
[
275-
'file' => 'State token does not match',
276-
],
277-
'guest'
278-
);
279-
$expected->setStatus(Http::STATUS_FORBIDDEN);
280-
$this->assertEquals($expected, $this->clientFlowLoginController->redirectPage('MyStateToken'));
281-
}
282-
283-
public function testRedirectPage() {
284-
$this->session
285-
->expects($this->at(0))
286-
->method('get')
287-
->with('client.flow.state.token')
288-
->willReturn('MyStateToken');
289-
$this->session
290-
->expects($this->at(1))
291-
->method('get')
292-
->with('oauth.state')
293-
->willReturn('MyOauthStateToken');
294-
295-
$expected = new TemplateResponse(
296-
'core',
297-
'loginflow/redirect',
298-
[
299-
'urlGenerator' => $this->urlGenerator,
300-
'stateToken' => 'MyStateToken',
301-
'clientIdentifier' => 'Identifier',
302-
'oauthState' => 'MyOauthStateToken',
303-
],
304-
'guest'
305-
);
306-
$this->assertEquals($expected, $this->clientFlowLoginController->redirectPage('MyStateToken', 'Identifier'));
307-
}
308-
309245
public function testGenerateAppPasswordWithInvalidToken() {
310246
$this->session
311247
->expects($this->once())

0 commit comments

Comments
 (0)