Skip to content

Commit fde594b

Browse files
authored
Merge pull request #3333 from microsoft/tedlee/fix-oauth-codebug
[OAuth] small oauth fix
2 parents 8f80ac5 + 607ab0c commit fde594b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

libraries/Microsoft.Bot.Builder/BotFrameworkAdapter.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,19 +826,25 @@ public virtual async Task<string> GetOauthSignInLinkAsync(ITurnContext turnConte
826826
throw new ArgumentNullException(nameof(userId));
827827
}
828828

829-
var appId = GetBotAppId(turnContext);
829+
var activity = turnContext.Activity;
830+
831+
if (!userId.Equals(activity.From?.Id))
832+
{
833+
throw new ArgumentException("cannot retrieve OAuth signin link for a user that's different from the conversation");
834+
}
830835

836+
var appId = GetBotAppId(turnContext);
831837
var tokenExchangeState = new TokenExchangeState()
832838
{
833839
ConnectionName = connectionName,
834840
Conversation = new ConversationReference()
835841
{
836-
ActivityId = null,
837-
Bot = new ChannelAccount { Role = "bot" },
838-
ChannelId = Channels.Directline,
839-
Conversation = new ConversationAccount(),
840-
ServiceUrl = null,
841-
User = new ChannelAccount { Role = "user", Id = userId, },
842+
ActivityId = activity.Id,
843+
Bot = activity.Recipient, // Activity is from the user to the bot
844+
ChannelId = activity.ChannelId,
845+
Conversation = activity.Conversation,
846+
ServiceUrl = activity.ServiceUrl,
847+
User = activity.From,
842848
},
843849
MsAppId = appId,
844850
};

0 commit comments

Comments
 (0)