diff --git a/src/components/ModWatchtools.jsx b/src/components/ModWatchtools.jsx index 4c2ec37..b35d0ff 100644 --- a/src/components/ModWatchtools.jsx +++ b/src/components/ModWatchtools.jsx @@ -60,7 +60,12 @@ async function submitWatchAction( method: 'POST', body: data, }); - const ret = await resp.json(); + let ret; + try { + ret = await resp.json(); + } catch { + throw new Error(await resp.text()); + } callback(await ret); } catch (err) { callback({ diff --git a/src/core/adminfunctions.js b/src/core/adminfunctions.js index b50858b..5333bbe 100644 --- a/src/core/adminfunctions.js +++ b/src/core/adminfunctions.js @@ -32,6 +32,12 @@ import { getIPofIID, getIIDofIP, } from '../data/sql/IPInfo'; +import { + getIIDSummary, + getIIDPixels, + getSummaryFromArea, + getPixelsFromArea, +} from './parsePixelLog'; import canvases from './canvases'; import { imageABGR2Canvas, @@ -258,6 +264,22 @@ export async function executeImageAction( } } +/* + * retgister responses on socket for Watch Actions + */ +socketEvents.onReq('watch', (action, ...args) => { + if (action === 'getIIDSummary') { + return getIIDSummary(...args); + } if (action === 'getIIDPixels') { + return getIIDPixels(...args); + } if (action === 'getSummaryFromArea') { + return getSummaryFromArea(...args); + } if (action === 'getPixelsFromArea') { + return getPixelsFromArea(...args); + } + return null; +}); + /* * Check who placed on a canvas area * @param action if every pixel or summary should be returned diff --git a/src/core/parsePixelLog.js b/src/core/parsePixelLog.js index 2373543..2dc749c 100644 --- a/src/core/parsePixelLog.js +++ b/src/core/parsePixelLog.js @@ -2,7 +2,6 @@ import fs from 'fs'; import readline from 'readline'; import { PIXELLOGGER_PREFIX } from './logger'; -import socketEvents from '../socket/socketEvents'; import { getNamesToIds } from '../data/sql/RegUser'; import { getIdsToIps, @@ -393,16 +392,3 @@ export async function getPixelsFromArea( rows, }; } - -socketEvents.onReq('watch', (action, ...args) => { - if (action === 'getIIDSummary') { - return getIIDSummary(...args); - } if (action === 'getIIDPixels') { - return getIIDPixels(...args); - } if (action === 'getSummaryFromArea') { - return getSummaryFromArea(...args); - } if (action === 'getPixelsFromArea') { - return getPixelsFromArea(...args); - } - return null; -}); diff --git a/src/routes/api/auth/change_mail.js b/src/routes/api/auth/change_mail.js index 4594b5c..7f0a0d3 100644 --- a/src/routes/api/auth/change_mail.js +++ b/src/routes/api/auth/change_mail.js @@ -7,14 +7,19 @@ import mailProvider from '../../../core/MailProvider'; import { validatePassword, validateEMail } from '../../../utils/validation'; import { getHostFromRequest } from '../../../utils/ip'; import { compareToHash } from '../../../utils/hash'; +import { checkIfMailDisposable } from '../../../core/isAllowed'; -function validate(email, password, gettext) { +async function validate(email, password, t, gettext) { const errors = []; const passerror = gettext(validatePassword(password)); if (passerror) errors.push(passerror); const mailerror = gettext(validateEMail(email)); - if (mailerror) errors.push(mailerror); + if (mailerror) { + errors.push(mailerror); + } else if (await checkIfMailDisposable(email)) { + errors.push(t`This email provider is not allowed`); + } return errors; } @@ -22,7 +27,7 @@ function validate(email, password, gettext) { export default async (req, res) => { const { email, password } = req.body; const { t, gettext } = req.ttag; - const errors = validate(email, password, gettext); + const errors = await validate(email, password, t, gettext); if (errors.length > 0) { res.status(400); res.json({ diff --git a/src/utils/ProxyCheck.js b/src/utils/ProxyCheck.js index 98dba52..158e92a 100644 --- a/src/utils/ProxyCheck.js +++ b/src/utils/ProxyCheck.js @@ -234,6 +234,7 @@ class ProxyCheck { this.fetching = false; this.checkFromQueue = this.checkFromQueue.bind(this); this.checkIp = this.checkIp.bind(this); + this.checkEmail = this.checkEmail.bind(this); this.pcKeyProvider = new PcKeyProvider(pcKeys, logger); this.logger = logger; } @@ -360,6 +361,7 @@ class ProxyCheck { let disposable = null; if (res[value]) { + this.logger.info(`Email ${value}: ${JSON.stringify(res[value])}`); disposable = !!res[value].disposable; } @@ -371,7 +373,7 @@ class ProxyCheck { let pcheck = 'N/A'; if (res[value]) { - this.logger.info(`${value}: ${JSON.stringify(res[value])}`); + this.logger.info(`IP ${value}: ${JSON.stringify(res[value])}`); const { proxy, type, city } = res[value]; allowed = proxy === 'no'; status = (allowed) ? 0 : 1;