Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App SSO Fixes #1003

Merged
merged 2 commits into from
Oct 23, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.Teams;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Extensions.Configuration;
Expand All @@ -13,9 +14,11 @@
{
public class AdapterWithErrorHandler : CloudAdapter
{
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<IBotFrameworkHttpAdapter> logger, ConversationState conversationState = null)
: base(auth, logger)
public AdapterWithErrorHandler(IConfiguration configuration, IStorage storage, BotFrameworkAuthentication auth, ILogger<IBotFrameworkHttpAdapter> logger, ConversationState conversationState = null)

Check warning on line 17 in samples/app-sso/csharp/App SSO Sample/AdapterWithErrorHandler.cs

View workflow job for this annotation

GitHub Actions / Build All "app-sso" csharp

Cannot convert null literal to non-nullable reference type.
: base(auth,logger)
{
base.Use(new TeamsSSOTokenExchangeMiddleware(storage, configuration["ConnectionName"]));

OnTurnError = async (turnContext, exception) =>
{
// Log any leaked exception from the application.
Expand Down
2 changes: 1 addition & 1 deletion samples/app-sso/csharp/App SSO Sample/Bots/DialogBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private async Task<TokenResponse> GetTokenResponse(ITurnContext<IInvokeActivity>
}

var userTokenClient = turnContext.TurnState.Get<UserTokenClient>();
var tokenResponse = await userTokenClient.GetUserTokenAsync(turnContext.Activity.From.Id, _connectionName, turnContext.Activity.ChannelId, magicCode, cancellationToken);
var tokenResponse = await userTokenClient.GetUserTokenAsync(turnContext.Activity.From.Id, _connectionName, turnContext.Activity.ChannelId, magicCode, cancellationToken).ConfigureAwait(false);

return tokenResponse;
}
Expand Down
23 changes: 14 additions & 9 deletions samples/app-sso/csharp/App SSO Sample/Dialogs/LogoutDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ public LogoutDialog(string id, string connectionName)
{
if (innerDc.Context.Activity.Type == ActivityTypes.Message)
{
var text = innerDc.Context.Activity.Text.ToLowerInvariant();

// Allow logout anywhere in the command
if (text.IndexOf("logout") >= 0)
var text = innerDc.Context.Activity.Text;
if (text != null)
{
// The bot adapter encapsulates the authentication processes.
var botAdapter = innerDc.Context.Adapter;
var userTokenClient = innerDc.Context.TurnState.Get<UserTokenClient>();
await userTokenClient.SignOutUserAsync(innerDc.Context.Activity.From.Id, ConnectionName, innerDc.Context.Activity.ChannelId, cancellationToken);
await innerDc.Context.SendActivityAsync(MessageFactory.Text("You have been signed out."), cancellationToken);
return await innerDc.CancelAllDialogsAsync(cancellationToken);
text = innerDc.Context.Activity.Text.ToLowerInvariant();

// Allow logout anywhere in the command
if (text.IndexOf("logout") >= 0)
{
// The bot adapter encapsulates the authentication processes.
var botAdapter = innerDc.Context.Adapter;
var userTokenClient = innerDc.Context.TurnState.Get<UserTokenClient>();
await userTokenClient.SignOutUserAsync(innerDc.Context.Activity.From.Id, ConnectionName, innerDc.Context.Activity.ChannelId, cancellationToken);
await innerDc.Context.SendActivityAsync(MessageFactory.Text("You have been signed out."), cancellationToken);
return await innerDc.CancelAllDialogsAsync(cancellationToken);
}
}
}

Expand Down
Loading