Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

A Possible solution for Issue #62) #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Node/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class BotAuthenticator {
throw new Error("options.baseUrl must be a valid url and start with 'https://'.");
}
}
if(!this.options.servicePath){
this.options.servicePath = this.options.basePath
}
if (!this.options.secret) {
throw new Error("options.secret can not be null");
}
Expand All @@ -53,9 +56,9 @@ class BotAuthenticator {
done(null, userId);
});
}
this.server.get(`/${this.options.basePath}/:providerId`, this.options.resumption.persistHandler(), this.passport_redirect());
this.server.get(`/${this.options.basePath}/:providerId/callback`, this.passport_callback(), this.options.resumption.restoreHandler(), this.credential_callback());
this.server.post(`/${this.options.basePath}/:providerId/callback`, this.passport_callback(), this.options.resumption.restoreHandler(), this.credential_callback());
this.server.get(`/${this.options.servicePath}/:providerId`, this.options.resumption.persistHandler(), this.passport_redirect());
this.server.get(`/${this.options.servicePath}/:providerId/callback`, this.passport_callback(), this.options.resumption.restoreHandler(), this.credential_callback());
this.server.post(`/${this.options.servicePath}/:providerId/callback`, this.passport_callback(), this.options.resumption.restoreHandler(), this.credential_callback());
this.bot.set("persistConversationData", true);
this.bot.set("persistUserData", true);
let lib = new builder.Library(consts_1.DIALOG_LIBRARY);
Expand Down
20 changes: 20 additions & 0 deletions Node/test/index-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,25 @@ describe('BotAuthenticator', function() {
let ba = new botauth.BotAuthenticator({}, {}, { baseUrl : "//botauth.azurewebsites.net", secret : "shhhhh" });
});
});

it('should default servicePath to botauth', function() {
let server = {
use : () => {},
get : (route,b,c) => {assert(route.startsWith('/botauth')) },
post : (route,b,c,e) => {assert(route.startsWith('/botauth'))}
};
let ba = new botauth.BotAuthenticator(server, mockBot, { baseUrl : "https://botauth.azurewebsites.net", secret : "shhhhh" });
assert.equal(ba.options.servicePath, 'botauth')
});

it('should override servicePath when set', function() {
let server = {
use : () => {},
get : (route,b,c) => {assert(route.startsWith('/servicePath')) },
post : (route,b,c,e) => {assert(route.startsWith('/servicePath'))}
};
let ba = new botauth.BotAuthenticator(server, mockBot, { baseUrl : "https://botauth.azurewebsites.net", secret : "shhhhh", servicePath: "servicePath" });
assert.equal(ba.options.servicePath, 'servicePath')
});
});
});