Skip to content

Commit 166a947

Browse files
Merge pull request #53296 from nextcloud/backport/53292/stable30
2 parents 709fa4b + 931aed3 commit 166a947

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

core/Controller/ClientFlowLoginController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
2020
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
2121
use OCP\AppFramework\Http\Attribute\OpenAPI;
22+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
2223
use OCP\AppFramework\Http\Attribute\PublicPage;
2324
use OCP\AppFramework\Http\Attribute\UseSession;
2425
use OCP\AppFramework\Http\Response;
@@ -214,6 +215,7 @@ public function grantPage(string $stateToken = '',
214215
*/
215216
#[NoAdminRequired]
216217
#[UseSession]
218+
#[PasswordConfirmationRequired(strict: false)]
217219
#[FrontpageRoute(verb: 'POST', url: '/login/flow')]
218220
public function generateAppPassword(string $stateToken,
219221
string $clientIdentifier = '',

core/Controller/ClientFlowLoginV2Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
1919
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
2020
use OCP\AppFramework\Http\Attribute\OpenAPI;
21+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
2122
use OCP\AppFramework\Http\Attribute\PublicPage;
2223
use OCP\AppFramework\Http\Attribute\UseSession;
2324
use OCP\AppFramework\Http\JSONResponse;
@@ -219,6 +220,7 @@ public function apptokenRedirect(?string $stateToken, string $user, string $pass
219220

220221
#[NoAdminRequired]
221222
#[UseSession]
223+
#[PasswordConfirmationRequired(strict: false)]
222224
#[FrontpageRoute(verb: 'POST', url: '/login/v2/grant')]
223225
public function generateAppPassword(?string $stateToken): Response {
224226
if ($stateToken === null) {

core/js/login/grant.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
document.querySelector('form').addEventListener('submit', function(e) {
5+
6+
const form = document.querySelector('form')
7+
form.addEventListener('submit', function(event) {
68
const wrapper = document.getElementById('submit-wrapper')
79
if (wrapper === null) {
810
return
911
}
12+
13+
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
14+
// stop the event
15+
event.preventDefault()
16+
event.stopPropagation()
17+
18+
// handle password confirmation
19+
OC.PasswordConfirmation.requirePasswordConfirmation(function () {
20+
// when password is confirmed we submit the form
21+
form.submit()
22+
})
23+
24+
return false
25+
}
26+
1027
Array.from(wrapper.getElementsByClassName('icon-confirm-white')).forEach(function(el) {
1128
el.classList.remove('icon-confirm-white')
1229
el.classList.add(OCA.Theming && OCA.Theming.inverted ? 'icon-loading-small' : 'icon-loading-small-dark')

0 commit comments

Comments
 (0)