From 92aef6b1807c70c6b798d809f36d1350eedfcde4 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 1 Jul 2020 23:48:04 +0300 Subject: [PATCH] Add API function and action for disabling MFA --- src/api/users.js | 10 ++++++++++ src/store/modules/users.js | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/api/users.js b/src/api/users.js index 642dd1a7..b62df5d7 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -62,6 +62,16 @@ export async function deleteUsers(nicknames, authHost, token) { }) } +export async function disableMfa(nickname, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/disable_mfa`, + method: 'put', + headers: authHeaders(token), + data: { nickname } + }) +} + export async function fetchUser(id, authHost, token) { return await request({ baseURL: baseName(authHost), diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 90b37e56..5f35bf44 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -7,6 +7,7 @@ import { deactivateUsers, deleteRight, deleteUsers, + disableMfa, fetchUsers, getPasswordResetToken, searchUsers, @@ -150,6 +151,14 @@ const users = { dispatch('ApplyChanges', { updatedUsers, callApiFn, userId: _userId }) }, + async DisableMfa({ dispatch, getters }, nickname) { + try { + await disableMfa(nickname, getters.authHost, getters.token) + } catch (_e) { + return + } + dispatch('SuccessMessage') + }, async ConfirmUsersEmail({ dispatch, getters }, { users, _userId, _statusId }) { const updatedUsers = users.map(user => { return { ...user, confirmation_pending: false }