- primo aggiornamento myreccard
- aggiunta sito germogliamo.app - aggiornato login con il parametro "browser_random" che serve per fare un login anche su 2 pagine contemporaneamente.
This commit is contained in:
@@ -296,9 +296,10 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, async (req, res) => {
|
||||
// Ritorna il token per poter effettuare le chiamate...
|
||||
router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
try {
|
||||
const body = _.pick(req.body, ['idapp', 'email', 'tokenforgot', 'tokenforgot_code', 'password']);
|
||||
const body = _.pick(req.body, ['idapp', 'email', 'tokenforgot', 'tokenforgot_code', 'password', 'br']);
|
||||
const idapp = body.idapp;
|
||||
const email = body.email.toLowerCase().trim();
|
||||
const browser_random = body.br;
|
||||
const tokenforgot = body.tokenforgot;
|
||||
const tokenforgot_code = body.tokenforgot_code;
|
||||
const password = body.password;
|
||||
@@ -347,6 +348,7 @@ router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
res
|
||||
.header('x-auth', ris.token)
|
||||
.header('x-refrtok', ris.refreshToken)
|
||||
.header('x-browser-random', ris.browser_random)
|
||||
.send({ code: server_constants.RIS_CODE_OK }); // Ritorna il token di ritorno
|
||||
});
|
||||
});
|
||||
@@ -2024,7 +2026,7 @@ async function testMongoPerformance(ind, iterations = 20) {
|
||||
const token =
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJQUk9WQU1TR0AxQSIsInNtYXJ0IjoiNjIwODAwYWRjMTI5ZDFlYmE3NjBiZWNiIiwiYWNjZXNzIjoiYXV0aCIsInVuIjoic3VyeWExOTc3IiwiaWF0IjoxNzQxODcyMzEwLCJleHAiOjE3NDE4Nzk1MTB9.SXJLmsS6EZVhaU7sUWYMnaqGpiiy8RfE9K43xTdxNuU';
|
||||
|
||||
await User.findByToken(token, 'auth', true, true);
|
||||
await User.findByToken(token, 'auth', '', true, true);
|
||||
}
|
||||
} catch (err) {
|
||||
log(`Errore nell'iterazione ${i + 1}: ${err.message}`);
|
||||
|
||||
@@ -37,6 +37,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
subscriptionModel.userId = req.body.others.userId;
|
||||
subscriptionModel.access = req.body.others.access;
|
||||
subscriptionModel.browser = req.get('User-Agent');
|
||||
subscriptionModel.browser_random = req.body.others.browser_random;
|
||||
|
||||
// console.log('subscriptionModel.browser', subscriptionModel.browser);
|
||||
|
||||
@@ -45,6 +46,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
userId: subscriptionModel.userId,
|
||||
access: subscriptionModel.access,
|
||||
browser: subscriptionModel.browser,
|
||||
browser_random: subscriptionModel.browser_random,
|
||||
}).then(itemsub => {
|
||||
return itemsub;
|
||||
}).catch(err => {
|
||||
@@ -96,8 +98,9 @@ router.delete('/del', authenticate, async (req, res) => {
|
||||
|
||||
if (req.user) {
|
||||
const browser = req.get('User-Agent');
|
||||
const browser_random = req.body.browser_random;
|
||||
return await Subscription.findOneAndDelete(
|
||||
{ userId: req.user._id, access: req.access, browser }).then(() => {
|
||||
{ userId: req.user._id, access: req.access, browser, browser_random }).then(() => {
|
||||
res.status(200).send();
|
||||
}, () => {
|
||||
res.status(400).send();
|
||||
|
||||
@@ -58,9 +58,9 @@ const mongoose = require('mongoose').set('debug', false);
|
||||
const Subscription = require('../models/subscribers');
|
||||
const Macro = require('../modules/Macro');
|
||||
|
||||
async function existSubScribe(userId, access, browser) {
|
||||
async function existSubScribe(userId, access, browser, browser_random) {
|
||||
try {
|
||||
const itemsub = await Subscription.findOne({ userId, access, browser }).lean();
|
||||
const itemsub = await Subscription.findOne({ userId, access, browser, browser_random }).lean();
|
||||
return itemsub;
|
||||
} catch (err) {
|
||||
return null;
|
||||
@@ -101,6 +101,7 @@ router.post('/', async (req, res) => {
|
||||
'lang',
|
||||
'profile',
|
||||
'aportador_solidario',
|
||||
'br',
|
||||
]);
|
||||
body.email = body.email.toLowerCase();
|
||||
|
||||
@@ -112,6 +113,8 @@ router.post('/', async (req, res) => {
|
||||
user.name = user.name.trim();
|
||||
user.surname = user.surname.trim();
|
||||
|
||||
const browser_random = body.br;
|
||||
|
||||
if (user.aportador_solidario === 'tuo_username' || user.aportador_solidario === '{username}') {
|
||||
user.aportador_solidario = 'surya1977';
|
||||
}
|
||||
@@ -313,8 +316,8 @@ router.post('/', async (req, res) => {
|
||||
// Invia la richiesta di ammissione all'Invitante!
|
||||
await telegrambot.askConfirmationUser(myuser.idapp, shared_consts.CallFunz.REGISTRATION, myuser);
|
||||
|
||||
const { token, refreshToken } = await myuser.generateAuthToken(req);
|
||||
res.header('x-auth', token).header('x-refrtok', refreshToken).send(myuser);
|
||||
const { token, refreshToken, browser_random } = await myuser.generateAuthToken(req, browser_random);
|
||||
res.header('x-auth', token).header('x-refrtok', refreshToken).header('x-browser-random', browser_random).send(myuser);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +330,7 @@ router.post('/', async (req, res) => {
|
||||
.then((usertrovato) => {
|
||||
// tools.mylog("TROVATO USERNAME ? ", user.username, usertrovato);
|
||||
if (usertrovato !== null) {
|
||||
return user.generateAuthToken(req);
|
||||
return user.generateAuthToken(req, browser_random);
|
||||
} else {
|
||||
res.status(400).send();
|
||||
return 0;
|
||||
@@ -365,7 +368,7 @@ router.post('/', async (req, res) => {
|
||||
// if (!tools.testing()) {
|
||||
await sendemail.sendEmail_Registration(user.lang, user.email, user, user.idapp, user.linkreg);
|
||||
// }
|
||||
res.header('x-auth', ris.token).header('x-refrtok', ris.refreshToken).send(user);
|
||||
res.header('x-auth', ris.token).header('x-refrtok', ris.refreshToken).header('x-browser-random', ris.browser_random).send(user);
|
||||
return true;
|
||||
});
|
||||
})
|
||||
@@ -667,7 +670,7 @@ router.post('/newtok', async (req, res) => {
|
||||
return res.status(403).send({ error: 'Refresh token non valido' });
|
||||
}
|
||||
|
||||
const { token, refreshToken: newRefreshToken } = await recFound.generateAuthToken(req);
|
||||
const { token, refreshToken: newRefreshToken } = await recFound.generateAuthToken(req, browser_random);
|
||||
|
||||
return res.status(200).send({
|
||||
token,
|
||||
@@ -708,8 +711,10 @@ function checkBlocked(req, res, next) {
|
||||
}
|
||||
|
||||
router.post('/login', checkBlocked, async (req, res) => {
|
||||
const body = _.pick(req.body, ['username', 'password', 'idapp', 'keyappid', 'lang']);
|
||||
const body = _.pick(req.body, ['username', 'password', 'idapp', 'keyappid', 'lang', 'br']);
|
||||
const userpass = new User(body);
|
||||
|
||||
const browser_random = body.br;
|
||||
// const subs = _.pick(req.body, ['subs']);
|
||||
|
||||
// tools.mylog("LOG: u: " + user.username + " p:" + user.password);
|
||||
@@ -783,7 +788,7 @@ router.post('/login', checkBlocked, async (req, res) => {
|
||||
|
||||
return res.status(401).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
|
||||
} else {
|
||||
const myris = await user.generateAuthToken(req);
|
||||
const myris = await user.generateAuthToken(req, browser_random);
|
||||
|
||||
const usertosend = new User();
|
||||
|
||||
@@ -791,7 +796,7 @@ router.post('/login', checkBlocked, async (req, res) => {
|
||||
usertosend[field] = user[field];
|
||||
});
|
||||
|
||||
const subsExistonDb = await existSubScribe(usertosend._id, 'auth', req.get('User-Agent'));
|
||||
const subsExistonDb = await existSubScribe(usertosend._id, 'auth', req.get('User-Agent'), myris.browser_random);
|
||||
|
||||
res.header('x-auth', myris.token).header('x-refrtok', myris.refreshToken).send({
|
||||
usertosend,
|
||||
|
||||
Reference in New Issue
Block a user