Skip to content

Commit

Permalink
Ensure that ABS OAuth cards are not sent by the Bot when (#1812)
Browse files Browse the repository at this point in the history
a community adapters is in use.

Co-authored-by: ckkMicrosoft <30480427+ckkMicrosoft@users.noreply.github.com>
Co-authored-by: Steven Ickman <stevenic@microsoft.com>
  • Loading branch information
3 people authored Mar 2, 2020
1 parent cddae34 commit 3f1ba32
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class OAuthPrompt extends Dialog {
if (!Array.isArray(msg.attachments)) { msg.attachments = []; }

// Add login card as needed
if (this.channelSupportsOAuthCard(context.activity.channelId)) {
if (this.isOAuthCardSupported(context)) {
const cards: Attachment[] = msg.attachments.filter((a: Attachment) => a.contentType === CardFactory.contentTypes.oauthCard);
if (cards.length === 0) {
let cardActionType = ActionTypes.Signin;
Expand Down Expand Up @@ -346,6 +346,26 @@ export class OAuthPrompt extends Dialog {
return activity.type === ActivityTypes.Invoke && activity.name === 'signin/verifyState';
}

private isOAuthCardSupported(context: TurnContext) {
// Azure Bot Service OAuth cards are not supported in the community adapters. Since community adapters
// have a 'name' in them, we cast the adapter to 'any' to check for the name.
const adapter:any = context.adapter;
if (adapter.name) {
switch(adapter.name) {
case 'Facebook Adapter':
case 'Google Hangouts Adapter':
case 'Slack Adapter':
case 'Twilio SMS Adapter':
case 'Web Adapter':
case 'Webex Adapter':
case 'Botkit CMS':
return false;
default:
}
}
return this.channelSupportsOAuthCard(context.activity.channelId);
}

private channelSupportsOAuthCard(channelId: string): boolean {
switch (channelId) {
case Channels.Msteams:
Expand Down

0 comments on commit 3f1ba32

Please sign in to comment.