From ad2d487beb1cb2918cc9fcf9c19471879392ed1e Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 28 Jan 2020 16:06:49 +0300 Subject: [PATCH] Fix forcing password reset --- src/api/users.js | 7 ++++--- src/store/modules/users.js | 7 ++++--- src/views/users/components/ModerationDropdown.vue | 6 +++--- src/views/users/components/MultipleUsersMenu.vue | 5 +++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/api/users.js b/src/api/users.js index 3755ee7c..8298eeca 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -89,12 +89,13 @@ export async function getPasswordResetToken(nickname, authHost, token) { }) } -export async function requirePasswordReset(nickname, authHost, token) { +export async function forcePasswordReset(nicknames, authHost, token) { return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/users/${nickname}/force_password_reset`, + url: `/api/pleroma/admin/users/force_password_reset`, method: 'patch', - headers: authHeaders(token) + headers: authHeaders(token), + data: { nicknames } }) } diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 9c0c594d..75b07402 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -12,7 +12,7 @@ import { searchUsers, tagUser, untagUser, - requirePasswordReset, + forcePasswordReset, confirmUserEmail, resendConfirmationEmail } from '@/api/users' @@ -207,9 +207,10 @@ const users = { dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: users[0].id }) }, - async RequirePasswordReset({ dispatch, getters }, user) { + async RequirePasswordReset({ dispatch, getters }, users) { + const nicknames = users.map(user => user.nickname) try { - await requirePasswordReset(user.nickname, getters.authHost, getters.token) + await forcePasswordReset(nicknames, getters.authHost, getters.token) } catch (_e) { return } diff --git a/src/views/users/components/ModerationDropdown.vue b/src/views/users/components/ModerationDropdown.vue index b44a7c01..892b8f39 100644 --- a/src/views/users/components/ModerationDropdown.vue +++ b/src/views/users/components/ModerationDropdown.vue @@ -95,7 +95,7 @@ + @click.native="requirePasswordReset(user)"> {{ $t('users.requirePasswordReset') }} @@ -136,13 +136,13 @@ export default { handleEmailConfirmation(user) { this.$store.dispatch('ConfirmUsersEmail', [user]) }, - requirePasswordReset(nickname) { + requirePasswordReset(user) { const mailerEnabled = this.$store.state.user.nodeInfo.metadata.mailerEnabled if (!mailerEnabled) { this.$alert(this.$t('users.mailerMustBeEnabled'), 'Error', { type: 'error' }) return } - this.$store.dispatch('RequirePasswordReset', { nickname }) + this.$store.dispatch('RequirePasswordReset', [user]) }, showAdminAction({ local, id }) { return local && this.showDeactivatedButton(id) diff --git a/src/views/users/components/MultipleUsersMenu.vue b/src/views/users/components/MultipleUsersMenu.vue index 1fdc029b..de058ad8 100644 --- a/src/views/users/components/MultipleUsersMenu.vue +++ b/src/views/users/components/MultipleUsersMenu.vue @@ -216,8 +216,9 @@ export default { }, requirePasswordReset: () => { const filtered = this.selectedUsers.filter(user => user.local) - filtered.map(user => this.$store.dispatch('RequirePasswordReset', user)) - this.$emit('apply-action') + const requirePasswordResetFn = async(users) => await this.$store.dispatch('RequirePasswordReset', users) + + applyAction(filtered, requirePasswordResetFn) }, confirmAccounts: () => { const filtered = this.selectedUsers.filter(user => user.local && user.confirmation_pending)