Fix forcing password reset

This commit is contained in:
Angelina Filippova 2020-01-28 16:06:49 +03:00
parent 47dbb5b8de
commit ad2d487beb
4 changed files with 14 additions and 11 deletions

View file

@ -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 }
})
}

View file

@ -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
}

View file

@ -95,7 +95,7 @@
</el-dropdown-item>
<el-dropdown-item
v-if="user.local"
@click.native="requirePasswordReset(user.nickname)">
@click.native="requirePasswordReset(user)">
{{ $t('users.requirePasswordReset') }}
</el-dropdown-item>
</el-dropdown-menu>
@ -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)

View file

@ -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)