forked from ppfun/pixelplanet
temporarily disallow muted users from deleting their accounts or
changing mail
This commit is contained in:
parent
0607c70f24
commit
016f6bf91a
|
@ -7,6 +7,7 @@ import mailProvider from '../../../core/MailProvider';
|
||||||
import { validatePassword, validateEMail } from '../../../utils/validation';
|
import { validatePassword, validateEMail } from '../../../utils/validation';
|
||||||
import { getHostFromRequest } from '../../../utils/ip';
|
import { getHostFromRequest } from '../../../utils/ip';
|
||||||
import { compareToHash } from '../../../utils/hash';
|
import { compareToHash } from '../../../utils/hash';
|
||||||
|
import { checkIfMuted } from '../../../data/redis/chat';
|
||||||
import { checkIfMailDisposable } from '../../../core/isAllowed';
|
import { checkIfMailDisposable } from '../../../core/isAllowed';
|
||||||
|
|
||||||
async function validate(email, password, t, gettext) {
|
async function validate(email, password, t, gettext) {
|
||||||
|
@ -54,6 +55,15 @@ export default async (req, res) => {
|
||||||
return;
|
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({
|
await user.regUser.update({
|
||||||
email,
|
email,
|
||||||
mailVerified: false,
|
mailVerified: false,
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import socketEvents from '../../../socket/socketEvents';
|
import socketEvents from '../../../socket/socketEvents';
|
||||||
import { RegUser } from '../../../data/sql';
|
import { RegUser } from '../../../data/sql';
|
||||||
import { validatePassword } from '../../../utils/validation';
|
import { validatePassword } from '../../../utils/validation';
|
||||||
|
import { checkIfMuted } from '../../../data/redis/chat';
|
||||||
import { compareToHash } from '../../../utils/hash';
|
import { compareToHash } from '../../../utils/hash';
|
||||||
|
|
||||||
function validate(password, gettext) {
|
function validate(password, gettext) {
|
||||||
|
@ -38,6 +39,15 @@ export default async (req, res) => {
|
||||||
}
|
}
|
||||||
const { id, name } = user;
|
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;
|
const currentPassword = user.regUser.password;
|
||||||
if (!currentPassword || !compareToHash(password, currentPassword)) {
|
if (!currentPassword || !compareToHash(password, currentPassword)) {
|
||||||
res.status(400);
|
res.status(400);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user