Added renewal request
This commit is contained in:
parent
84b096594b
commit
1f83141f1c
@ -53,7 +53,7 @@ class WNSAuth extends EventEmitter
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
Register( ChannelUri, handler )
|
Register( uuid, ChannelUri, handler )
|
||||||
{
|
{
|
||||||
var _self = this;
|
var _self = this;
|
||||||
var VerifyChannel = () =>
|
var VerifyChannel = () =>
|
||||||
@ -64,7 +64,14 @@ class WNSAuth extends EventEmitter
|
|||||||
, message: "Registration success"
|
, message: "Registration success"
|
||||||
});
|
});
|
||||||
|
|
||||||
var uuid = Rand.uuid();
|
if( uuid )
|
||||||
|
{
|
||||||
|
Dragonfly.Info( "Renewal request: " + uuid );
|
||||||
|
this.__updateToken( uuid, ChannelUri, handler );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid = Rand.uuid();
|
||||||
|
|
||||||
_self.__send( ChannelUri, N, ( sender, e ) => {
|
_self.__send( ChannelUri, N, ( sender, e ) => {
|
||||||
|
|
||||||
@ -76,24 +83,7 @@ class WNSAuth extends EventEmitter
|
|||||||
|
|
||||||
if( e.statusCode == 200 )
|
if( e.statusCode == 200 )
|
||||||
{
|
{
|
||||||
Model.Tokens.update(
|
this.__updateToken( uuid, ChannelUri, handler );
|
||||||
{ name: uuid }
|
|
||||||
, { name: uuid, token: ChannelUri }
|
|
||||||
, { upsert: true }
|
|
||||||
)
|
|
||||||
.exec( ( err, data ) => {
|
|
||||||
|
|
||||||
if( err )
|
|
||||||
{
|
|
||||||
Dragonfly.Error( err );
|
|
||||||
handler( _self, "Server Error: Cannot save channel information" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success
|
|
||||||
handler( _self, uuid );
|
|
||||||
} );
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +137,28 @@ class WNSAuth extends EventEmitter
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__updateToken( uuid, ChannelUri, handler )
|
||||||
|
{
|
||||||
|
var _self = this;
|
||||||
|
Model.Tokens.update(
|
||||||
|
{ name: uuid }
|
||||||
|
, { name: uuid, token: ChannelUri }
|
||||||
|
, { upsert: true }
|
||||||
|
)
|
||||||
|
.exec( ( err, data ) => {
|
||||||
|
|
||||||
|
if( err )
|
||||||
|
{
|
||||||
|
Dragonfly.Error( err );
|
||||||
|
handler( _self, "Server Error: Cannot save channel information" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Success
|
||||||
|
handler( _self, uuid );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
__send( ChannelUri, NotisQ, handler )
|
__send( ChannelUri, NotisQ, handler )
|
||||||
{
|
{
|
||||||
if( !ChannelUri )
|
if( !ChannelUri )
|
||||||
|
@ -16,8 +16,24 @@ class App extends Base
|
|||||||
constructor( Http )
|
constructor( Http )
|
||||||
{
|
{
|
||||||
super( Http );
|
super( Http );
|
||||||
|
|
||||||
|
// Everything here is plain text
|
||||||
|
this.HTTP.response.headers[ "Content-Type" ] = "text/plain; charset=utf-8";
|
||||||
|
|
||||||
this.result = "Hello there! This is a notify-term server.\nFor more information please head to https://github.com/tgckpg/notify-term";
|
this.result = "Hello there! This is a notify-term server.\nFor more information please head to https://github.com/tgckpg/notify-term";
|
||||||
|
|
||||||
|
if( !this.HTTP.request.isPost )
|
||||||
|
{
|
||||||
|
if( this.HTTP.request.uri.path != "/" )
|
||||||
|
{
|
||||||
|
this.result = "This site has no static content";
|
||||||
|
this.HTTP.response.statusCode = 404;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.plantResult();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.OAuth = new WNSAuth();
|
this.OAuth = new WNSAuth();
|
||||||
this.OAuth.addListener( "AuthComplete", this.OnAuthed.bind( this ) );
|
this.OAuth.addListener( "AuthComplete", this.OnAuthed.bind( this ) );
|
||||||
this.OAuth.Authenticate();
|
this.OAuth.Authenticate();
|
||||||
@ -51,7 +67,7 @@ class App extends Base
|
|||||||
{
|
{
|
||||||
case "register":
|
case "register":
|
||||||
this.OAuth.Register(
|
this.OAuth.Register(
|
||||||
query.uri, ( sender, mesg ) => {
|
query.id, query.uri, ( sender, mesg ) => {
|
||||||
_self.result = mesg;
|
_self.result = mesg;
|
||||||
_self.plantResult();
|
_self.plantResult();
|
||||||
} );
|
} );
|
||||||
|
Loading…
Reference in New Issue
Block a user