- Add saldo to member's list
This commit is contained in:
@@ -504,6 +504,86 @@ CircuitSchema.statics.getUserCircuits = async function(idapp, username) {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getUsersSingleCircuit = async function(idapp, username, circuitname, circuitId) {
|
||||
|
||||
const {User} = require('../models/user');
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {
|
||||
idapp: idapp,
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: circuitname}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
/*{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
as: 'circuit',
|
||||
let: {circuitname: circuitname, idapp: '$idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$name', '$$circuitname']},
|
||||
{$eq: ['$idapp', '$$idapp']},
|
||||
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
},
|
||||
{$unwind: '$circuit'},
|
||||
*/
|
||||
{
|
||||
$project: {username: 1, profile: 1, idapp: 1 /*, 'circuit.name': 1, 'circuit._id': 1*/},
|
||||
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
as: 'account',
|
||||
let: {username: '$username', idapp: '$idapp', circuitId: circuitId /*, circuitId: '$circuit._id' */ },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
{$eq: ['$$circuitId', '$circuitId']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{$unwind: '$account'},
|
||||
];
|
||||
|
||||
ris = await User.aggregate(aggr1);
|
||||
|
||||
return ris;
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircolanteSingolaTransaz = function(accountorigTable, accountdestTable) {
|
||||
|
||||
let circolante = 0;
|
||||
@@ -647,7 +727,7 @@ CircuitSchema.statics.updateData = async function(idapp, circuitname) {
|
||||
};
|
||||
const risult = await this.updateOne({idapp, name: circuitname}, {$set: paramstoupdate});
|
||||
|
||||
console.log('risult', risult)
|
||||
console.log('risult', risult);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
|
||||
@@ -1238,15 +1238,21 @@ UserSchema.statics.createNewReqRegistrationGetLink = async function(idapp, usern
|
||||
});
|
||||
|
||||
if (user) {
|
||||
if (!user.date_tokenreg || (user.tokenreg && (user.date_tokenreg < new Date().getTime()))) {
|
||||
if (!user.date_tokenreg || (!user.tokenreg) || (user.tokenreg && (user.date_tokenreg < new Date().getTime()))) {
|
||||
// Se è scaduto, ne crea uno nuovo
|
||||
// Creo il tokenforgot
|
||||
user.tokenreg = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).
|
||||
toString();
|
||||
|
||||
user.tokenreg = user.tokenreg.replaceAll('.', '');
|
||||
user.tokenreg = user.tokenreg.replaceAll('/', '');
|
||||
user.tokenreg = user.tokenreg.substring(1,8);
|
||||
if (user.tokenreg){
|
||||
try {
|
||||
user.tokenreg = user.tokenreg.replaceAll('.', '');
|
||||
user.tokenreg = user.tokenreg.replaceAll('/', '');
|
||||
user.tokenreg = user.tokenreg.substring(1,8);
|
||||
}catch (e) {
|
||||
console.error('err', e);
|
||||
}
|
||||
}
|
||||
|
||||
user.date_tokenreg = tools.AddDate(new Date(), 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user