- aggiornamento con proj RISO. postcss, pwa.

This commit is contained in:
Surya Paolo
2025-03-05 18:14:09 +01:00
parent f3597facd3
commit f6d8e1bb0b
5 changed files with 31 additions and 16 deletions

View File

@@ -1,12 +1,12 @@
DATABASE=test_PiuCheBuono
DATABASE=test_FreePlanet
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["1","17"]
appTelegram=["1","17"]
appTelegram_DEVELOP=["17"]
appTelegram_TEST=["1","13"]
appTelegram=["1","13"]
appTelegram_DEVELOP=["13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=0
ENABLE_PUSHNOTIFICATION=1
@@ -38,9 +38,4 @@ FTPSERVER_PWD=ftpmypwd@1A_
AUTH_NEW_SITES=123123123
SCRIPTS_DIR=admin_scripts
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
MIAB_HOST=box.lamiaposta.org
MIAB_ADMIN_EMAIL=admin@lamiaposta.org
MIAB_ADMIN_PASSWORD=passpao1pabox@1A
DS_API_KEY="sk-222e3addb3d8455d8b0516d93906eec7"
API_KEY_MSSQL="m68yADSr123MIVIDA@154$DSAGVOK"
SERVER_A_URL="http://51.77.156.69:3000"

View File

@@ -30,7 +30,9 @@ const authenticate = (req, res, next) => {
const access = 'auth';
return User.findByToken(token, access, true).then((ris) => {
const idapp = getIdApp(req);
return User.findByToken(token, access, true, idapp).then((ris) => {
if (ris && ris.user && !!ris.user.deleted) {
if (ris.user.deleted)
@@ -70,14 +72,26 @@ const authenticate = (req, res, next) => {
});
};
const getIdApp = (req) => {
let idapp = null;
try {
idapp = req.query.idapp;
} catch (e) {
console.log('IDAPP NON TROVATO !');
}
return idapp;
}
const authenticate_noerror = (req, res, next) => {
try {
const token = req.header('x-auth');
const refreshToken = req.header('x-refrtok');
const access = 'auth';
const idapp = getIdApp(req);
return User.findByToken(token, access, false).then((ris) => {
const access = 'auth';
return User.findByToken(token, access, false, idapp).then((ris) => {
if (ris.code !== server_constants.RIS_CODE_OK) {
req.user = null;
req.token = null;

View File

@@ -731,7 +731,7 @@ UserSchema.statics.isFacilitatore = function (perm) {
}
};
UserSchema.statics.findByToken = async function (token, typeaccess, con_auth) {
UserSchema.statics.findByToken = async function (token, typeaccess, con_auth, idapp) {
const User = this;
let decoded;
let code = server_constants.RIS_CODE_HTTP_INVALID_TOKEN;
@@ -758,10 +758,15 @@ UserSchema.statics.findByToken = async function (token, typeaccess, con_auth) {
}
if (code === server_constants.RIS_CODE_OK) {
user = await User.findOne({
'_id': decoded.smart,
'tokens.token': token,
'tokens.access': typeaccess,
tokens: {
$elemMatch: {
token: token,
access: typeaccess,
},
},
});
if (user) {

View File

@@ -72,6 +72,7 @@ router.post('/', authenticate, async (req, res) => {
// console.log('req.body', req.body)
if (req.body.options !== null) {
// Invia una notifica PUSH (asincrona)
tools.sendBackNotif(subscription, req.body.options);
}
// console.log('Subscription saved... ')

View File

@@ -852,7 +852,7 @@ module.exports = {
return myrec._doc;
},
sendBackNotif: function (subscription, payload) {
sendBackNotif: async function (subscription, payload) {
const Subscription = require('../models/subscribers');
// console.log('sendBackNotif:', subscription, payload);