throw if trying to overwrite time in non-test env
This commit is contained in:
parent
3873e43f39
commit
f53ba3822c
16
index.js
16
index.js
@ -120,11 +120,9 @@ totp.gen = function(key, opt) {
|
|||||||
|
|
||||||
// Time has been overwritten.
|
// Time has been overwritten.
|
||||||
if(opt._t) {
|
if(opt._t) {
|
||||||
console.log('#####################################');
|
if(process.env.NODE_ENV != 'test') {
|
||||||
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #');
|
throw new Error('cannot overwrite time in non-test environment!');
|
||||||
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #');
|
}
|
||||||
console.log('# USED FOR TEST PURPOSES. #');
|
|
||||||
console.log('#####################################');
|
|
||||||
_t = opt._t;
|
_t = opt._t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,11 +170,9 @@ totp.verify = function(token, key, opt) {
|
|||||||
|
|
||||||
// Time has been overwritten.
|
// Time has been overwritten.
|
||||||
if(opt._t) {
|
if(opt._t) {
|
||||||
console.log('#####################################');
|
if(process.env.NODE_ENV != 'test') {
|
||||||
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #');
|
throw new Error('cannot overwrite time in non-test environment!');
|
||||||
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #');
|
}
|
||||||
console.log('# USED FOR TEST PURPOSES. #');
|
|
||||||
console.log('#####################################');
|
|
||||||
_t = opt._t;
|
_t = opt._t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha"
|
"test": "NODE_ENV=test mocha"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= v0.6.0"
|
"node": ">= v0.6.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user