Merge pull request #9 from freewil/throw-time-overwrite

throw if trying to overwrite time in non-test env
This commit is contained in:
Guy Halford-Thompson 2014-04-09 09:08:57 -07:00
commit d10c328292
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"