Skip to content

Commit 37b46df

Browse files
committed
fix(core): prompt for password once when installing recommended apps
Wire the password-confirmation interceptors into the recommendedapps entry point and switch the installer to a single bulk enable call so the strict password confirmation on enableApps is satisfied. Fixes #60068 -e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent bae205f commit 37b46df

7 files changed

Lines changed: 119 additions & 34 deletions

File tree

core/src/components/setup/RecommendedApps.vue

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
import axios from '@nextcloud/axios'
6363
import { loadState } from '@nextcloud/initial-state'
6464
import { t } from '@nextcloud/l10n'
65+
import { PwdConfirmationMode } from '@nextcloud/password-confirmation'
6566
import { generateUrl, imagePath } from '@nextcloud/router'
66-
import pLimit from 'p-limit'
6767
import NcButton from '@nextcloud/vue/components/NcButton'
6868
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
6969
import logger from '../../logger.js'
@@ -147,35 +147,41 @@ export default {
147147
},
148148
149149
methods: {
150-
installApps() {
151-
this.installingApps = true
152-
153-
const limit = pLimit(1)
154-
const installing = this.recommendedApps
150+
async installApps() {
151+
const apps = this.recommendedApps
155152
.filter((app) => !app.active && app.isCompatible && app.canInstall && app.isSelected)
156-
.map((app) => limit(async () => {
157-
logger.info(`installing ${app.id}`)
158-
app.loading = true
159-
return axios.post(generateUrl('settings/apps/enable'), { appIds: [app.id], groups: [] })
160-
.catch((error) => {
161-
logger.error(`could not install ${app.id}`, { error })
162-
app.isSelected = false
163-
app.installationError = true
164-
})
165-
.then(() => {
166-
logger.info(`installed ${app.id}`)
167-
app.loading = false
168-
app.active = true
169-
})
170-
}))
171-
logger.debug(`installing ${installing.length} recommended apps`)
172-
Promise.all(installing)
173-
.then(() => {
174-
logger.info('all recommended apps installed, redirecting …')
175-
176-
window.location = this.defaultPageUrl
153+
if (apps.length === 0) {
154+
return
155+
}
156+
157+
this.installingApps = true
158+
apps.forEach((app) => {
159+
app.loading = true
160+
})
161+
const appIds = apps.map((app) => app.id)
162+
logger.debug(`installing ${apps.length} recommended apps`, { appIds })
163+
164+
try {
165+
await axios.post(
166+
generateUrl('settings/apps/enable'),
167+
{ appIds, groups: [] },
168+
{ confirmPassword: PwdConfirmationMode.Strict },
169+
)
170+
apps.forEach((app) => {
171+
app.loading = false
172+
app.active = true
177173
})
178-
.catch((error) => logger.error('could not install recommended apps', { error }))
174+
logger.info('all recommended apps installed, redirecting …')
175+
window.location = this.defaultPageUrl
176+
} catch (error) {
177+
logger.error('could not install recommended apps', { error })
178+
apps.forEach((app) => {
179+
app.loading = false
180+
app.isSelected = false
181+
app.installationError = true
182+
})
183+
this.installingApps = false
184+
}
179185
},
180186
181187
customIcon(appId) {

core/src/recommendedapps.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
*/
55

66
import { getCSPNonce } from '@nextcloud/auth'
7+
import axios from '@nextcloud/axios'
78
import { translate as t } from '@nextcloud/l10n'
9+
import { addPasswordConfirmationInterceptors } from '@nextcloud/password-confirmation'
810
import Vue from 'vue'
911
import RecommendedApps from './components/setup/RecommendedApps.vue'
1012
import logger from './logger.js'
1113

14+
addPasswordConfirmationInterceptors(axios)
15+
1216
__webpack_nonce__ = getCSPNonce()
1317

1418
Vue.mixin({

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-recommendedapps.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-recommendedapps.js.license

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
44
SPDX-License-Identifier: BSD-3-Clause
55
SPDX-License-Identifier: AGPL-3.0-or-later
66
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
7+
SPDX-FileCopyrightText: webfansplz
8+
SPDX-FileCopyrightText: perfect-debounce developers
9+
SPDX-FileCopyrightText: hookable developers
710
SPDX-FileCopyrightText: escape-html developers
11+
SPDX-FileCopyrightText: debounce developers
12+
SPDX-FileCopyrightText: atomiks
813
SPDX-FileCopyrightText: Tobias Koppers @sokra
914
SPDX-FileCopyrightText: T. Jameson Little <t.jameson.little@gmail.com>
1015
SPDX-FileCopyrightText: Roman Shtylman <shtylman@gmail.com>
@@ -13,11 +18,21 @@ SPDX-FileCopyrightText: Matt Zabriskie
1318
SPDX-FileCopyrightText: GitHub Inc.
1419
SPDX-FileCopyrightText: Feross Aboukhadijeh
1520
SPDX-FileCopyrightText: Evan You
21+
SPDX-FileCopyrightText: Eduardo San Martin Morote
1622
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
23+
SPDX-FileCopyrightText: David Clark
1724
SPDX-FileCopyrightText: Christoph Wurst
25+
SPDX-FileCopyrightText: Anthony Fu <https://github.com/antfu>
26+
SPDX-FileCopyrightText: Anthony Fu <anthonyfu117@hotmail.com>
1827

1928

2029
This file is generated from multiple sources. Included packages:
30+
- @floating-ui/core
31+
- version: 1.7.5
32+
- license: MIT
33+
- @floating-ui/utils
34+
- version: 0.2.11
35+
- license: MIT
2136
- @nextcloud/auth
2237
- version: 2.5.3
2338
- license: GPL-3.0-or-later
@@ -27,6 +42,9 @@ This file is generated from multiple sources. Included packages:
2742
- @nextcloud/browser-storage
2843
- version: 0.5.0
2944
- license: GPL-3.0-or-later
45+
- @nextcloud/capabilities
46+
- version: 1.2.1
47+
- license: GPL-3.0-or-later
3048
- semver
3149
- version: 7.7.2
3250
- license: ISC
@@ -42,6 +60,48 @@ This file is generated from multiple sources. Included packages:
4260
- @nextcloud/logger
4361
- version: 3.0.3
4462
- license: GPL-3.0-or-later
63+
- @nextcloud/vue
64+
- version: 9.6.0
65+
- license: AGPL-3.0-or-later
66+
- @vue/devtools-shared
67+
- version: 8.1.0
68+
- license: MIT
69+
- @vue/reactivity
70+
- version: 3.5.30
71+
- license: MIT
72+
- @vue/runtime-core
73+
- version: 3.5.30
74+
- license: MIT
75+
- @vue/runtime-dom
76+
- version: 3.5.30
77+
- license: MIT
78+
- @vue/shared
79+
- version: 3.5.30
80+
- license: MIT
81+
- @vueuse/core
82+
- version: 14.2.1
83+
- license: MIT
84+
- @vueuse/shared
85+
- version: 14.2.1
86+
- license: MIT
87+
- perfect-debounce
88+
- version: 2.1.0
89+
- license: MIT
90+
- @vue/devtools-api
91+
- version: 8.1.0
92+
- license: MIT
93+
- @vue/devtools-kit
94+
- version: 8.1.0
95+
- license: MIT
96+
- vue-router
97+
- version: 5.0.3
98+
- license: MIT
99+
- vue
100+
- version: 3.5.30
101+
- license: MIT
102+
- @nextcloud/password-confirmation
103+
- version: 6.1.0
104+
- license: MIT
45105
- @nextcloud/router
46106
- version: 3.1.0
47107
- license: GPL-3.0-or-later
@@ -54,15 +114,27 @@ This file is generated from multiple sources. Included packages:
54114
- base64-js
55115
- version: 1.5.1
56116
- license: MIT
117+
- birpc
118+
- version: 2.9.0
119+
- license: MIT
57120
- css-loader
58121
- version: 7.1.2
59122
- license: MIT
123+
- debounce
124+
- version: 3.0.0
125+
- license: MIT
60126
- dompurify
61127
- version: 3.4.0
62128
- license: (MPL-2.0 OR Apache-2.0)
63129
- escape-html
64130
- version: 1.0.3
65131
- license: MIT
132+
- focus-trap
133+
- version: 8.0.1
134+
- license: MIT
135+
- hookable
136+
- version: 5.5.3
137+
- license: MIT
66138
- ieee754
67139
- version: 1.2.1
68140
- license: BSD-3-Clause
@@ -75,6 +147,9 @@ This file is generated from multiple sources. Included packages:
75147
- style-loader
76148
- version: 4.0.0
77149
- license: MIT
150+
- tabbable
151+
- version: 6.4.0
152+
- license: MIT
78153
- vue-loader
79154
- version: 15.11.1
80155
- license: MIT

dist/core-recommendedapps.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)