Skip to content

Commit

Permalink
Fix logger level, make user id and name opitional
Browse files Browse the repository at this point in the history
  • Loading branch information
boydc2014 committed May 25, 2024
1 parent 973685f commit e2ee89e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public DirectlineController(IBotFrameworkHttpAdapter adapter, IBot bot, ILogger<
{
_adapter = adapter;
_bot = bot;
_logger = logger;
}

[HttpPost("tokens/generate")]
Expand All @@ -50,14 +51,19 @@ public async Task<object> TokenGenerate()
}
catch (JsonException)
{
_logger.LogTrace("The request body is not a valid JSON object");
_logger.LogError("The request body is not a valid JSON object");
return BadRequest("The request body is not a valid JSON object");
}

if (tokenGenerationParameters?.user?.Id == null || tokenGenerationParameters?.user?.Name == null)
{
_logger.LogTrace("The user parameter is required");
return BadRequest("The user parameter is required");
_logger.LogWarning("No user specified, using default user id and name");
tokenGenerationParameters = new TokenGenerationParameters();
tokenGenerationParameters.user = new TokenGenerationParameters.User
{
Id = "default-user-id",
Name = "default-user-name"
};
}

// We just encode the user id and name in the token for this sample
Expand Down

0 comments on commit e2ee89e

Please sign in to comment.