Merge branch 'github-master'
This commit is contained in:
commit
b0e52f3d6a
@ -121,7 +121,7 @@ class WNSAuth extends EventEmitter
|
|||||||
{
|
{
|
||||||
var _self = this;
|
var _self = this;
|
||||||
Model.Tokens
|
Model.Tokens
|
||||||
.findOne({ name: NotisQ.id })
|
.findOne({ name: NotisQ.id, expired: false })
|
||||||
.exec( ( err, data ) => {
|
.exec( ( err, data ) => {
|
||||||
if( err )
|
if( err )
|
||||||
{
|
{
|
||||||
@ -134,8 +134,19 @@ class WNSAuth extends EventEmitter
|
|||||||
this.__send( data.token, NotisQ, ( sender, e ) => {
|
this.__send( data.token, NotisQ, ( sender, e ) => {
|
||||||
Dragonfly.Debug( "Send: " + e.statusCode );
|
Dragonfly.Debug( "Send: " + e.statusCode );
|
||||||
|
|
||||||
if( e.statusCode != 200 )
|
switch( e.statusCode )
|
||||||
{
|
{
|
||||||
|
case 200: break;
|
||||||
|
case 410:
|
||||||
|
Dragonfly.Info( "Channel is expired: " + NotisQ.id );
|
||||||
|
data.expired = true;
|
||||||
|
data.save( x => {
|
||||||
|
Dragonfly.Info( "Mark expired: " + NotisQ.id );
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
AuthToken = null;
|
AuthToken = null;
|
||||||
Dragonfly.Info( "Perhaps access token is expired, retrying ..." );
|
Dragonfly.Info( "Perhaps access token is expired, retrying ..." );
|
||||||
|
|
||||||
@ -167,7 +178,12 @@ class WNSAuth extends EventEmitter
|
|||||||
var _self = this;
|
var _self = this;
|
||||||
Model.Tokens.update(
|
Model.Tokens.update(
|
||||||
{ name: uuid }
|
{ name: uuid }
|
||||||
, { name: uuid, token: ChannelUri, date_created: Date.now() }
|
, {
|
||||||
|
name: uuid
|
||||||
|
, token: ChannelUri
|
||||||
|
, date_created: Date.now()
|
||||||
|
, expired: false
|
||||||
|
}
|
||||||
, { upsert: true }
|
, { upsert: true }
|
||||||
)
|
)
|
||||||
.exec( ( err, data ) => {
|
.exec( ( err, data ) => {
|
||||||
@ -256,7 +272,10 @@ class WNSAuth extends EventEmitter
|
|||||||
, { name: AuthTokenName, token: AuthToken, date_created: Date.now() }
|
, { name: AuthTokenName, token: AuthToken, date_created: Date.now() }
|
||||||
, { upsert: true }
|
, { upsert: true }
|
||||||
)
|
)
|
||||||
.exec( ( err, data ) => _self.__emitAuthComplete() );
|
.exec( ( err, data ) => {
|
||||||
|
if( err ) Dragonfly.Error( err );
|
||||||
|
_self.__emitAuthComplete();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,6 @@ var HttpRequest = cl.load( "botanss.net.HttpRequest" );
|
|||||||
var Base = cl.load( "botanss.net.PostFrame" );
|
var Base = cl.load( "botanss.net.PostFrame" );
|
||||||
|
|
||||||
var WNSAuth = cl.load( "notifyterm.WNSAuth" );
|
var WNSAuth = cl.load( "notifyterm.WNSAuth" );
|
||||||
var Model = cl.load( "notifyterm.schema" );
|
|
||||||
var NotisQ = cl.load( "notifyterm.Notis" );
|
var NotisQ = cl.load( "notifyterm.Notis" );
|
||||||
var SrvAuth = cl.load( "notifyterm.config.auth" );
|
var SrvAuth = cl.load( "notifyterm.config.auth" );
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ var R_Tokens = { type: Schema.Types.ObjectId, ref: "Tokens" };
|
|||||||
var M_Tokens = new Schema({
|
var M_Tokens = new Schema({
|
||||||
name: { type: String, unique: true }
|
name: { type: String, unique: true }
|
||||||
, token: { type: String }
|
, token: { type: String }
|
||||||
|
, expired: { type: Boolean, default: false }
|
||||||
, date_created: {
|
, date_created: {
|
||||||
type: Date
|
type: Date
|
||||||
, default: Date.now
|
, default: Date.now
|
||||||
|
Loading…
Reference in New Issue
Block a user