Added remove action
This commit is contained in:
		@@ -82,15 +82,21 @@ class WNSAuth extends EventEmitter
 | 
			
		||||
						, { upsert: true }
 | 
			
		||||
					)
 | 
			
		||||
					.exec( ( err, data ) => {
 | 
			
		||||
 | 
			
		||||
						if( err )
 | 
			
		||||
						{
 | 
			
		||||
							Dragonfly.Error( err );
 | 
			
		||||
							handler( _self, "Server Error: Cannot save channel information" );
 | 
			
		||||
							return;
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						// Success
 | 
			
		||||
						handler( _self, uuid );
 | 
			
		||||
					} );
 | 
			
		||||
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				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 )
 | 
			
		||||
	{
 | 
			
		||||
		Model.Tokens
 | 
			
		||||
@@ -120,7 +137,7 @@ class WNSAuth extends EventEmitter
 | 
			
		||||
			if( data && data.token )
 | 
			
		||||
			{
 | 
			
		||||
				this.__send( data.token, NotisQ, ( sender, e ) => {
 | 
			
		||||
					Dragonfly.Debug( e.Data );
 | 
			
		||||
					Dragonfly.Debug( "Send: " + e.statusCode );
 | 
			
		||||
				} );
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,23 @@ class App extends Base
 | 
			
		||||
			case "deliver":
 | 
			
		||||
				this.__sendMesg( query );
 | 
			
		||||
				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:
 | 
			
		||||
				this.result = "Invalid Action";
 | 
			
		||||
				this.plantResult();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user