Skip to content

Commit 6e6b4ef

Browse files
committed
fix: handle IDLE timeout
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 3e7909a commit 6e6b4ef

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

core/Controller/ClientFlowLoginController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use OCA\OAuth2\Db\ClientMapper;
4242
use OCP\AppFramework\Controller;
4343
use OCP\AppFramework\Http;
44+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
4445
use OCP\AppFramework\Http\Attribute\UseSession;
4546
use OCP\AppFramework\Http\Response;
4647
use OCP\AppFramework\Http\StandaloneTemplateResponse;
@@ -254,6 +255,7 @@ public function grantPage(string $stateToken = '',
254255
* @return Http\RedirectResponse|Response
255256
*/
256257
#[UseSession]
258+
#[PasswordConfirmationRequired]
257259
public function generateAppPassword(string $stateToken,
258260
string $clientIdentifier = '') {
259261
if (!$this->isValidToken($stateToken)) {

core/Controller/ClientFlowLoginV2Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use OC\Core\Service\LoginFlowV2Service;
3434
use OCP\AppFramework\Controller;
3535
use OCP\AppFramework\Http;
36+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
3637
use OCP\AppFramework\Http\Attribute\UseSession;
3738
use OCP\AppFramework\Http\JSONResponse;
3839
use OCP\AppFramework\Http\RedirectResponse;
@@ -236,6 +237,7 @@ public function apptokenRedirect(?string $stateToken, string $user, string $pass
236237
* @NoAdminRequired
237238
*/
238239
#[UseSession]
240+
#[PasswordConfirmationRequired]
239241
public function generateAppPassword(?string $stateToken): Response {
240242
if ($stateToken === null) {
241243
return $this->stateTokenMissingResponse();

core/js/login/grant.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
document.querySelector('form').addEventListener('submit', function(e) {
1+
/**
2+
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
const form = document.querySelector('form')
7+
form.addEventListener('submit', function(event) {
28
const wrapper = document.getElementById('submit-wrapper')
39
if (wrapper === null) {
410
return
511
}
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+
627
Array.from(wrapper.getElementsByClassName('icon-confirm-white')).forEach(function(el) {
728
el.classList.remove('icon-confirm-white')
829
el.classList.add(OCA.Theming && OCA.Theming.inverted ? 'icon-loading-small' : 'icon-loading-small-dark')

0 commit comments

Comments
 (0)