Commit ad2d487b authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Fix forcing password reset

parent 47dbb5b8
Pipeline #22333 failed with stages
in 8 minutes and 33 seconds
......@@ -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 }
})
}
......
......@@ -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
}
......
......@@ -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)
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment