refs #6264 perf: remove files related to token
This commit is contained in:
parent
d4cd23853f
commit
b9671c0b67
|
@ -1,9 +0,0 @@
|
||||||
const tokenConfig = require('./token-config');
|
|
||||||
|
|
||||||
module.exports = async token => {
|
|
||||||
const accessTokenConfig = await tokenConfig();
|
|
||||||
const now = Date.now();
|
|
||||||
const differenceMilliseconds = now - token.created;
|
|
||||||
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
|
|
||||||
return differenceSeconds < accessTokenConfig.renewPeriod - accessTokenConfig.courtesyTime;
|
|
||||||
};
|
|
|
@ -1,9 +0,0 @@
|
||||||
const DEFAULT_FIELDS = ['renewPeriod', 'courtesyTime'];
|
|
||||||
const {models} = require('vn-loopback/server/server');
|
|
||||||
let currentAccessTokenConfig = null;
|
|
||||||
module.exports = async(fields = DEFAULT_FIELDS) => {
|
|
||||||
if (currentAccessTokenConfig) return currentAccessTokenConfig;
|
|
||||||
const accessTokenConfig = await models.AccessTokenConfig.findOne({fields});
|
|
||||||
if (!accessTokenConfig) currentAccessTokenConfig = accessTokenConfig;
|
|
||||||
return accessTokenConfig;
|
|
||||||
};
|
|
Loading…
Reference in New Issue