temporarily disallow muted users from deleting their accounts or

changing mail
This commit is contained in:
HF 2023-03-18 18:14:49 +01:00
parent 0607c70f24
commit 016f6bf91a
2 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import mailProvider from '../../../core/MailProvider';
import { validatePassword, validateEMail } from '../../../utils/validation';
import { getHostFromRequest } from '../../../utils/ip';
import { compareToHash } from '../../../utils/hash';
import { checkIfMuted } from '../../../data/redis/chat';
import { checkIfMailDisposable } from '../../../core/isAllowed';
async function validate(email, password, t, gettext) {
@ -54,6 +55,15 @@ export default async (req, res) => {
return;
}
const mutedTtl = await checkIfMuted(user.id);
if (mutedTtl !== -2) {
res.status(403);
res.json({
errors: [t`Muted users can not do this.`],
});
return;
}
await user.regUser.update({
email,
mailVerified: false,

View File

@ -5,6 +5,7 @@
import socketEvents from '../../../socket/socketEvents';
import { RegUser } from '../../../data/sql';
import { validatePassword } from '../../../utils/validation';
import { checkIfMuted } from '../../../data/redis/chat';
import { compareToHash } from '../../../utils/hash';
function validate(password, gettext) {
@ -38,6 +39,15 @@ export default async (req, res) => {
}
const { id, name } = user;
const mutedTtl = await checkIfMuted(id);
if (mutedTtl !== -2) {
res.status(403);
res.json({
errors: [t`Muted users can not delete their account.`],
});
return;
}
const currentPassword = user.regUser.password;
if (!currentPassword || !compareToHash(password, currentPassword)) {
res.status(400);