From 1d5d3b2a3628195b4a31a3989e8d83bc0b2164d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Fri, 12 Feb 2016 21:16:36 +0800 Subject: [PATCH] expiration handler --- notify-term/WNSAuth.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notify-term/WNSAuth.js b/notify-term/WNSAuth.js index 9610a0a..841f74a 100644 --- a/notify-term/WNSAuth.js +++ b/notify-term/WNSAuth.js @@ -37,7 +37,7 @@ class WNSAuth extends EventEmitter this.__inAuth = true; var _self = this; - Model.Tokens.findOne({ name: AuthTokenName }) + Model.Tokens.findOne({ name: AuthTokenName, date_created: { $gt: Date.now() - 83200 } }) .exec( ( err, data ) => { if( err || !( data && data.token ) ) { @@ -142,7 +142,7 @@ class WNSAuth extends EventEmitter var _self = this; Model.Tokens.update( { name: uuid } - , { name: uuid, token: ChannelUri } + , { name: uuid, token: ChannelUri, date_created: Date.now() } , { upsert: true } ) .exec( ( err, data ) => { @@ -226,7 +226,7 @@ class WNSAuth extends EventEmitter Model.Tokens .update( { name: AuthTokenName } - , { name: AuthTokenName, token: AuthToken } + , { name: AuthTokenName, token: AuthToken, date_created: Date.now() } , { upsert: true } ) .exec( ( err, data ) => _self.__emitAuthComplete() );