throw if trying to overwrite time in non-test env

This commit is contained in:
freewil 2014-04-07 04:11:03 -07:00
parent 3873e43f39
commit f53ba3822c
2 changed files with 7 additions and 11 deletions

View File

@ -120,11 +120,9 @@ totp.gen = function(key, opt) {
// Time has been overwritten.
if(opt._t) {
console.log('#####################################');
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #');
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #');
console.log('# USED FOR TEST PURPOSES. #');
console.log('#####################################');
if(process.env.NODE_ENV != 'test') {
throw new Error('cannot overwrite time in non-test environment!');
}
_t = opt._t;
}
@ -172,11 +170,9 @@ totp.verify = function(token, key, opt) {
// Time has been overwritten.
if(opt._t) {
console.log('#####################################');
console.log('# NOTE: TOTP TIME VARIABLE HAS BEEN #');
console.log('# OVERWRITTEN. THIS SHOULD ONLY BE #');
console.log('# USED FOR TEST PURPOSES. #');
console.log('#####################################');
if(process.env.NODE_ENV != 'test') {
throw new Error('cannot overwrite time in non-test environment!');
}
_t = opt._t;
}

View File

@ -10,7 +10,7 @@
},
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "NODE_ENV=test mocha"
},
"engines": {
"node": ">= v0.6.0"