Skip to content

Commit

Permalink
new(all): ENABLE_AUTH param.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed May 10, 2021
1 parent ac9d065 commit 25c9d45
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 1 deletion.
42 changes: 42 additions & 0 deletions packages/admin.gbapp/dialogs/AdminDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export class AdminDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/admin-auth', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;
const prompt = Messages[locale].authenticate;
Expand All @@ -98,6 +106,14 @@ export class AdminDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/admin', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;
const prompt = Messages[locale].authenticate;
Expand Down Expand Up @@ -181,6 +197,14 @@ export class AdminDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/install', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
step.activeDialog.state.options.args = (step.options as any).args;
if (step.activeDialog.state.options.confirm) {
Expand Down Expand Up @@ -212,6 +236,15 @@ export class AdminDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/publish', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
if (step.activeDialog.state.options.confirm || process.env.ADMIN_OPEN_PUBLISH === "true") {
return await step.next('sim');
Expand Down Expand Up @@ -332,6 +365,15 @@ export class AdminDialog extends IGBDialog {
private static setupSecurityDialogs(min: GBMinInstance) {
min.dialogs.add(
new WaterfallDialog('/setupSecurity', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;
const prompt = Messages[locale].enter_authenticator_tenant;
Expand Down
11 changes: 10 additions & 1 deletion packages/core.gbapp/dialogs/BroadcastDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ export class BroadcastDialog extends IGBDialog {
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add(
new WaterfallDialog('/gb-broadcast', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;

return await min.conversationalService.prompt(min, step, 'Type the message and the broadcast will start.');
},
async step => {
await min.conversationalService['broadcast'](min, step.result);
// DISABLED: await min.conversationalService['broadcast'](min, step.result);
return await step.next();
}
])
Expand Down
8 changes: 8 additions & 0 deletions packages/core.gbapp/dialogs/LanguageDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export class LanguageDialog extends IGBDialog {
*/
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add(new WaterfallDialog('/language', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;
Expand Down
8 changes: 8 additions & 0 deletions packages/core.gbapp/dialogs/SwitchBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export class SwitchBotDialog extends IGBDialog {
*/
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add(new WaterfallDialog('/bot', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;
Expand Down
8 changes: 8 additions & 0 deletions packages/core.gbapp/dialogs/WelcomeDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export class WelcomeDialog extends IGBDialog {

min.dialogs.add(new WaterfallDialog('/', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {

if (GBServer.globals.entryPointDialog !== null &&
min.instance.botId === process.env.BOT_ID &&
Expand Down
9 changes: 9 additions & 0 deletions packages/core.gbapp/dialogs/WhoAmIDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export class WhoAmIDialog extends IGBDialog {
*/
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add(new WaterfallDialog('/whoAmI', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;
await min.conversationalService.sendText(min, step, `${min.instance.description}`);
Expand Down
32 changes: 32 additions & 0 deletions packages/customer-satisfaction.gbapp/dialogs/FeedbackDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ export class FeedbackDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/t', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {

const locale = step.context.activity.locale;
Expand Down Expand Up @@ -101,6 +109,14 @@ export class FeedbackDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/qt', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {

const locale = step.context.activity.locale;
Expand Down Expand Up @@ -173,6 +189,14 @@ export class FeedbackDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/feedbackNumber', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;

Expand All @@ -192,6 +216,14 @@ export class FeedbackDialog extends IGBDialog {

min.dialogs.add(
new WaterfallDialog('/feedback', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;

Expand Down
25 changes: 25 additions & 0 deletions packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export class AskDialog extends IGBDialog {
private static getAskDialog(min: GBMinInstance) {
return [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;
const user = await min.userProfile.get(step.context, {});
user.isAsking = true;
Expand Down Expand Up @@ -144,6 +152,14 @@ export class AskDialog extends IGBDialog {
private static getAnswerDialog(min: GBMinInstance, service: KBService) {
return [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
let answer: GuaribasAnswer = null;
const user = await min.userProfile.get(step.context, {});

Expand Down Expand Up @@ -258,6 +274,15 @@ export class AskDialog extends IGBDialog {

private static getAnswerEventDialog(service: KBService, min: GBMinInstance) {
return [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const data = step.options as AskDialogArgs;
if (data !== undefined && data.questionId !== undefined) {
Expand Down
9 changes: 9 additions & 0 deletions packages/kb.gbapp/dialogs/FaqDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export class FaqDialog extends IGBDialog {
const service = new KBService(min.core.sequelize);

min.dialogs.add(new WaterfallDialog('/faq', [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const data = await service.getFaqBySubjectArray(min.instance.instanceId, 'faq', undefined);
const locale = step.context.activity.locale;
Expand Down
9 changes: 9 additions & 0 deletions packages/kb.gbapp/dialogs/MenuDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ export class MenuDialog extends IGBDialog {

private static getMenuDialog(min: GBMinInstance, service: KBService) {
return [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},

async step => {
const locale = step.context.activity.locale;
const user = await min.userProfile.get(step.context, {});
Expand Down
32 changes: 32 additions & 0 deletions packages/security.gbapp/dialogs/ProfileDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export class ProfileDialog extends IGBDialog {

return {
id: '/profile_name', waterfall: [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
step.activeDialog.state.options = step.options;
const locale = step.context.activity.locale;
Expand Down Expand Up @@ -87,6 +95,14 @@ export class ProfileDialog extends IGBDialog {

return {
id: '/profile_mobile', waterfall: [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
step.activeDialog.state.options = step.options;
const locale = step.context.activity.locale;
Expand Down Expand Up @@ -121,6 +137,14 @@ export class ProfileDialog extends IGBDialog {

return {
id: '/profile_mobile_confirm', waterfall: [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
step.activeDialog.state.options = step.options;
const locale = step.context.activity.locale;
Expand Down Expand Up @@ -151,6 +175,14 @@ export class ProfileDialog extends IGBDialog {
public static getEmailDialog(min: GBMinInstance) {
return {
id: '/profile_email', waterfall: [
async step => {
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
return await step.beginDialog('/auth');
}
else{
return await step.next(step.options);
}
},
async step => {
const locale = step.context.activity.locale;
await step.prompt('textPrompt', Messages[locale].whats_email);
Expand Down

0 comments on commit 25c9d45

Please sign in to comment.