Aggiornata Chiave Segreta per accesso SIGNCODE.

- Inserito autenticazione MongoDB ai database.
-PCB: Aggiunto altri campi a products
This commit is contained in:
Surya Paolo
2023-12-07 08:34:24 +01:00
parent d5bc76335f
commit 4871c2d868
10 changed files with 140 additions and 20 deletions

View File

@@ -512,7 +512,8 @@ UserSchema.methods.generateAuthToken = function (req) {
const access = 'auth';
const browser = useragent;
const token = jwt.sign({ _id: user._id.toHexString(), access },
const prova = 'PROVAMSG@1A'
const token = jwt.sign({ _id: prova, smart: user._id.toHexString(), access, un: user.username },
process.env.SIGNCODE).toString();
const date_login = new Date();
@@ -670,7 +671,7 @@ UserSchema.statics.findByToken = function (token, typeaccess) {
}
return User.findOne({
'_id': decoded._id,
'_id': decoded.smart,
'tokens.token': token,
'tokens.access': typeaccess,
});
@@ -687,7 +688,7 @@ UserSchema.statics.findByTokenAnyAccess = function (token) {
}
return User.findOne({
'_id': decoded._id,
'_id': decoded.smart,
'tokens.token': token,
});
};
@@ -1290,7 +1291,7 @@ UserSchema.statics.createNewRequestPwd = function (idapp, email, code) {
return { ris: false };
} else {
// Creo il tokenforgot
user.tokenforgot = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).
user.tokenforgot = jwt.sign({_id: 'prova123##', smart: user._id.toHexString()}, process.env.SIGNCODE).
toString();
user.date_tokenforgot = new Date();
user.tokenforgot_code = 100000 + Math.round(Math.random() * 899999);
@@ -1316,8 +1317,12 @@ UserSchema.statics.createNewRequestPwdByUsernameAndGetLink = async function (ida
});
if (user) {
const additionalData = {
code: user.username,
};
const prova = 'dasdas1231#11';
// Creo il tokenforgot
user.tokenforgot = jwt.sign(user._id.toHexString(), process.env.SIGNCODE).
user.tokenforgot = jwt.sign({_id: prova, smart: user._id.toHexString(), ...additionalData}, process.env.SIGNCODE).
toString();
user.date_tokenforgot = new Date();
user.tokenforgot_code = 100000 + Math.round(Math.random() * 899999);