new(all): ENABLE_AUTH param.

This commit is contained in:
Rodrigo Rodriguez 2021-05-10 10:53:53 -03:00
parent ac9d065a61
commit 25c9d45ab2
11 changed files with 192 additions and 1 deletions

View file

@ -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;
@ -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;
@ -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) {
@ -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');
@ -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;

View file

@ -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();
}
])

View file

@ -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;

View file

@ -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;

View file

@ -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 &&

View file

@ -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}`);

View file

@ -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;
@ -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;
@ -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;
@ -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;

View file

@ -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;
@ -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, {});
@ -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) {

View file

@ -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;

View file

@ -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, {});

View file

@ -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;
@ -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;
@ -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;
@ -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);