expiration handler

This commit is contained in:
斟酌 鵬兄 2016-02-12 21:16:36 +08:00
parent e1ec75b88d
commit 1d5d3b2a36

View File

@ -37,7 +37,7 @@ class WNSAuth extends EventEmitter
this.__inAuth = true; this.__inAuth = true;
var _self = this; var _self = this;
Model.Tokens.findOne({ name: AuthTokenName }) Model.Tokens.findOne({ name: AuthTokenName, date_created: { $gt: Date.now() - 83200 } })
.exec( ( err, data ) => { .exec( ( err, data ) => {
if( err || !( data && data.token ) ) if( err || !( data && data.token ) )
{ {
@ -142,7 +142,7 @@ class WNSAuth extends EventEmitter
var _self = this; var _self = this;
Model.Tokens.update( Model.Tokens.update(
{ name: uuid } { name: uuid }
, { name: uuid, token: ChannelUri } , { name: uuid, token: ChannelUri, date_created: Date.now() }
, { upsert: true } , { upsert: true }
) )
.exec( ( err, data ) => { .exec( ( err, data ) => {
@ -226,7 +226,7 @@ class WNSAuth extends EventEmitter
Model.Tokens Model.Tokens
.update( .update(
{ name: AuthTokenName } { name: AuthTokenName }
, { name: AuthTokenName, token: AuthToken } , { name: AuthTokenName, token: AuthToken, date_created: Date.now() }
, { upsert: true } , { upsert: true }
) )
.exec( ( err, data ) => _self.__emitAuthComplete() ); .exec( ( err, data ) => _self.__emitAuthComplete() );