Skip to content

Commit 8226b01

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 fb67d5d commit 8226b01

2 files changed

Lines changed: 38 additions & 28 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({

0 commit comments

Comments
 (0)