refs #6427 perf: minor changes
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-03-26 08:26:44 +01:00
parent 7ddf0ad1a5
commit 06ed466953
1 changed files with 2 additions and 3 deletions

View File

@ -1,4 +1,5 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const maxTTL = ((60 * 1000) * 5); // 5 min
module.exports = authCode = async(vnUser, options) => { module.exports = authCode = async(vnUser, options) => {
const myOptions = {}; const myOptions = {};
@ -7,11 +8,9 @@ module.exports = authCode = async(vnUser, options) => {
Object.assign(myOptions, options); Object.assign(myOptions, options);
const code = String(Math.floor(Math.random() * 999999)); const code = String(Math.floor(Math.random() * 999999));
console.log(code);
const maxTTL = ((60 * 1000) * 5); // 5 min
await models.AuthCode.upsertWithWhere({userFk: vnUser.id}, { await models.AuthCode.upsertWithWhere({userFk: vnUser.id}, {
userFk: vnUser.id, userFk: vnUser.id,
code: code, code,
expires: Date.vnNow() + maxTTL expires: Date.vnNow() + maxTTL
}, myOptions); }, myOptions);
return code; return code;