Added remove action

This commit is contained in:
斟酌 鵬兄 2016-02-12 05:10:14 +08:00
parent bc77a9d371
commit e1f2926f64
2 changed files with 35 additions and 1 deletions

View File

@ -82,15 +82,21 @@ class WNSAuth extends EventEmitter
, { upsert: true } , { upsert: true }
) )
.exec( ( err, data ) => { .exec( ( err, data ) => {
if( err ) if( err )
{ {
Dragonfly.Error( err ); Dragonfly.Error( err );
handler( _self, "Server Error: Cannot save channel information" ); handler( _self, "Server Error: Cannot save channel information" );
return; return;
} }
// Success
handler( _self, uuid ); handler( _self, uuid );
} ); } );
return;
} }
handler( _self, e.statusCode + " Server Error: Unable to push message to channel" ); handler( _self, e.statusCode + " Server Error: Unable to push message to channel" );
} ); } );
}; };
@ -106,6 +112,17 @@ class WNSAuth extends EventEmitter
} }
} }
Unregister( uuid, handler )
{
if( uuid == AuthTokenName )
{
handler( "Malicious action: Trying to remove AuthToken" );
return;
}
Model.Tokens.remove({ name: uuid }).exec( handler );
}
Deliver( NotisQ ) Deliver( NotisQ )
{ {
Model.Tokens Model.Tokens
@ -120,7 +137,7 @@ class WNSAuth extends EventEmitter
if( data && data.token ) if( data && data.token )
{ {
this.__send( data.token, NotisQ, ( sender, e ) => { this.__send( data.token, NotisQ, ( sender, e ) => {
Dragonfly.Debug( e.Data ); Dragonfly.Debug( "Send: " + e.statusCode );
} ); } );
} }
else else

View File

@ -45,6 +45,23 @@ class App extends Base
case "deliver": case "deliver":
this.__sendMesg( query ); this.__sendMesg( query );
break; break;
case "remove":
this.OAuth.Unregister( query.id, ( err, data ) => {
if( err )
{
Dragonfly.Error( err );
}
else
{
Dragonfly.Debug( "Removed " + query.id + ": " + data );
}
_self.result = "OK";
_self.plantResult();
} );
break;
default: default:
this.result = "Invalid Action"; this.result = "Invalid Action";
this.plantResult(); this.plantResult();