Debugging V4 and adding some security logic.

This commit is contained in:
Rodrigo Rodriguez 2018-09-03 13:43:09 -03:00
parent 2584717ae8
commit f6bf1068bb
6 changed files with 190 additions and 68 deletions

View file

@ -58,7 +58,7 @@ export class AdminDialog extends IGBDialog {
await dc.prompt('textPrompt', prompt);
},
async (dc, value) => {
var text = value.response;
let text = value;
const user = min.userState.get(dc.context);
if (
@ -123,6 +123,9 @@ export class AdminDialog extends IGBDialog {
dc.replace("/admin", {
firstRun: false
});
} else if (text.split(" ")[0] === "rat") {
min.conversationalService.sendEvent(dc, "play", { playerType: "login", data: null });
dc.context.sendActivity("Realize login clicando no botão de login, por favor...");
}
}
])

View file

@ -56,6 +56,7 @@ export class WelcomeDialog extends IGBDialog {
date < 12 ? "bom dia" : date < 18 ? "boa tarde" : "boa noite";
let messages = [`Oi, ${msg}.`, `Oi!`, `Olá, ${msg}`, `Olá!`];
dc.context.sendActivity(messages[0]);
if (dc.context.activity && dc.context.activity.text != "") {
await dc.replace("/answer", { query: dc.context.activity.text });

View file

@ -246,7 +246,12 @@ export class GBMinService {
min.conversationalService.sendEvent(
dc,
"loadInstance",
min.instance // TODO: Send just necessary values.
{
instanceId: instance.instanceId,
botId: instance.botId,
theme: instance.theme,
secret: instance.webchatKey, // TODO: Use token.
}
);
user.loaded = true;
@ -263,10 +268,12 @@ export class GBMinService {
// Check to see if anyone replied. If not then start echo dialog
if (!context.responded) {
if (!user.once) {
await dc.begin('/');
} else if (context.activity.name === "whoAmI") {
dc.begin("/whoAmI");
} else if (context.activity.text === "admin") {
dc.begin("/admin");
} else if (context.activity.name === "showSubjects") {
dc.begin("/menu");
} else if (context.activity.name === "giveFeedback") {

View file

@ -1,6 +1,6 @@
{
"name": "default.gbui",
"version": "0.0.10",
"version": "0.0.11",
"private": true,
"homepage": ".",
"dependencies": {
@ -8,6 +8,7 @@
"botframework-webchat": "^0.14.2",
"deep-extend": "^0.6.0",
"fetch": "^1.1.0",
"msal": "^0.2.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-helmet": "^5.2.0",

View file

@ -34,6 +34,7 @@ import React from "react";
import GBMarkdownPlayer from "./players/GBMarkdownPlayer.js";
import GBImagePlayer from "./players/GBImagePlayer.js";
import GBVideoPlayer from "./players/GBVideoPlayer.js";
import GBLoginPlayer from "./players/GBLoginPlayer.js";
import GBBulletPlayer from "./players/GBBulletPlayer.js";
import SidebarMenu from "./components/SidebarMenu.js";
import GBCss from "./components/GBCss.js";
@ -223,6 +224,16 @@ class GBUIApp extends React.Component {
/>
);
break;
case "login":
playerComponent = (
<GBLoginPlayer
app={this}
ref={player => {
this.player = player;
}}
/>
);
break;
default:
console.log(
"GBERROR: Unknow player type specified on message from server."

View file

@ -0,0 +1,99 @@
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of Pragmatismo.io. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
import React from "react";
import { UserAgentApplication } from "msal";
class GBLoginPlayer extends React.Component {
constructor() {
super();
this.state = {
token: "",
};
}
login() {
let config = {
tenant: "pragmatismo.onmicrosoft.com", //"6ecb2a67-15af-4582-ab85-cc65096ce471",
signUpSignInPolicy: "b2c_1_susi",
clientID: '47cbaa05-dbb4-46f8-8608-da386c5131f1'}
let authority = "https://login.microsoftonline.com/tfp/" +
config.tenant + "/" +
config.signUpSignInPolicy;
let userAgentApplication = new UserAgentApplication(
config.clientID, authority,
function (errorDesc, token, error, tokenType) {
console.log(token);
}
);
let graphScopes = ["Directory.AccessAsUser.All"];
userAgentApplication.loginPopup(graphScopes).then(function (idToken) {
userAgentApplication.acquireTokenSilent(graphScopes).then(function (accessToken) {
console.log(accessToken);
}, function (error) {
userAgentApplication.acquireTokenPopup(graphScopes).then(function (accessToken) {
console.log(accessToken);
}, function (error) {
console.log(error);
});
})
}, function (error) {
console.log(error);
});
}
play() {
}
render() {
return (
<button
value="Login"
onClick={this.login}
/>
);
}
}
export default GBLoginPlayer;