Merge pull request #9 from freewil/throw-time-overwrite
throw if trying to overwrite time in non-test env
This commit is contained in:
commit
d10c328292
16
index.js
16
index.js
@ -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;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
"test": "NODE_ENV=test mocha"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= v0.6.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user