fix: replace logic in isPrivilegedOrSelfAndPasswordMatch to use privileges.users.canEdit

isekai-main
Julian Lam 3 years ago
parent 87ba768f5c
commit 856ba78a5f

@ -227,14 +227,9 @@ usersAPI.unban = async function (caller, data) {
async function isPrivilegedOrSelfAndPasswordMatch(caller, data) {
const { uid } = caller;
const isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
const canEdit = await privileges.users.canEdit(uid, data.uid);
const [isAdmin, isTargetAdmin, isGlobalMod] = await Promise.all([
user.isAdministrator(uid),
user.isAdministrator(data.uid),
user.isGlobalModerator(uid),
]);
if ((isTargetAdmin && !isAdmin) || (!isSelf && !(isAdmin || isGlobalMod))) {
if (!canEdit) {
throw new Error('[[error:no-privileges]]');
}
const [hasPassword, passwordMatch] = await Promise.all([

Loading…
Cancel
Save