fix little issues
This commit is contained in:
parent
0ba7063d9e
commit
5b18952c27
|
@ -60,7 +60,12 @@ async function submitWatchAction(
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data,
|
body: data,
|
||||||
});
|
});
|
||||||
const ret = await resp.json();
|
let ret;
|
||||||
|
try {
|
||||||
|
ret = await resp.json();
|
||||||
|
} catch {
|
||||||
|
throw new Error(await resp.text());
|
||||||
|
}
|
||||||
callback(await ret);
|
callback(await ret);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback({
|
callback({
|
||||||
|
|
|
@ -32,6 +32,12 @@ import {
|
||||||
getIPofIID,
|
getIPofIID,
|
||||||
getIIDofIP,
|
getIIDofIP,
|
||||||
} from '../data/sql/IPInfo';
|
} from '../data/sql/IPInfo';
|
||||||
|
import {
|
||||||
|
getIIDSummary,
|
||||||
|
getIIDPixels,
|
||||||
|
getSummaryFromArea,
|
||||||
|
getPixelsFromArea,
|
||||||
|
} from './parsePixelLog';
|
||||||
import canvases from './canvases';
|
import canvases from './canvases';
|
||||||
import {
|
import {
|
||||||
imageABGR2Canvas,
|
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
|
* Check who placed on a canvas area
|
||||||
* @param action if every pixel or summary should be returned
|
* @param action if every pixel or summary should be returned
|
||||||
|
|
|
@ -2,7 +2,6 @@ import fs from 'fs';
|
||||||
import readline from 'readline';
|
import readline from 'readline';
|
||||||
|
|
||||||
import { PIXELLOGGER_PREFIX } from './logger';
|
import { PIXELLOGGER_PREFIX } from './logger';
|
||||||
import socketEvents from '../socket/socketEvents';
|
|
||||||
import { getNamesToIds } from '../data/sql/RegUser';
|
import { getNamesToIds } from '../data/sql/RegUser';
|
||||||
import {
|
import {
|
||||||
getIdsToIps,
|
getIdsToIps,
|
||||||
|
@ -393,16 +392,3 @@ export async function getPixelsFromArea(
|
||||||
rows,
|
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;
|
|
||||||
});
|
|
||||||
|
|
|
@ -7,14 +7,19 @@ 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 { checkIfMailDisposable } from '../../../core/isAllowed';
|
||||||
|
|
||||||
function validate(email, password, gettext) {
|
async function validate(email, password, t, gettext) {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|
||||||
const passerror = gettext(validatePassword(password));
|
const passerror = gettext(validatePassword(password));
|
||||||
if (passerror) errors.push(passerror);
|
if (passerror) errors.push(passerror);
|
||||||
const mailerror = gettext(validateEMail(email));
|
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;
|
return errors;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +27,7 @@ function validate(email, password, gettext) {
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { email, password } = req.body;
|
const { email, password } = req.body;
|
||||||
const { t, gettext } = req.ttag;
|
const { t, gettext } = req.ttag;
|
||||||
const errors = validate(email, password, gettext);
|
const errors = await validate(email, password, t, gettext);
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
res.status(400);
|
res.status(400);
|
||||||
res.json({
|
res.json({
|
||||||
|
|
|
@ -234,6 +234,7 @@ class ProxyCheck {
|
||||||
this.fetching = false;
|
this.fetching = false;
|
||||||
this.checkFromQueue = this.checkFromQueue.bind(this);
|
this.checkFromQueue = this.checkFromQueue.bind(this);
|
||||||
this.checkIp = this.checkIp.bind(this);
|
this.checkIp = this.checkIp.bind(this);
|
||||||
|
this.checkEmail = this.checkEmail.bind(this);
|
||||||
this.pcKeyProvider = new PcKeyProvider(pcKeys, logger);
|
this.pcKeyProvider = new PcKeyProvider(pcKeys, logger);
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
@ -360,6 +361,7 @@ class ProxyCheck {
|
||||||
let disposable = null;
|
let disposable = null;
|
||||||
|
|
||||||
if (res[value]) {
|
if (res[value]) {
|
||||||
|
this.logger.info(`Email ${value}: ${JSON.stringify(res[value])}`);
|
||||||
disposable = !!res[value].disposable;
|
disposable = !!res[value].disposable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +373,7 @@ class ProxyCheck {
|
||||||
let pcheck = 'N/A';
|
let pcheck = 'N/A';
|
||||||
|
|
||||||
if (res[value]) {
|
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];
|
const { proxy, type, city } = res[value];
|
||||||
allowed = proxy === 'no';
|
allowed = proxy === 'no';
|
||||||
status = (allowed) ? 0 : 1;
|
status = (allowed) ? 0 : 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user