Skip to content

Commit

Permalink
Decontruct result from getting tenant id and webapi url.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyYates authored and martincostello committed Dec 15, 2022
1 parent 2ec4b74 commit b2f8527
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
[NotNull] AuthenticationProperties properties,
[NotNull] OAuthTokenResponse tokens)
{
var contextId = await ProcessIdTokenAndGetContactIdentifierAsync(tokens, properties, identity);
(string tenantId, string webApiUrl) = await ProcessIdTokenAndGetContactIdentifierAsync(tokens, properties, identity);

if (string.IsNullOrEmpty(contextId.TenantId))
if (string.IsNullOrEmpty(tenantId))
{
throw new InvalidOperationException("An error occurred trying to obtain the context identifier from the current user's identity claims.");
}

if (string.IsNullOrEmpty(contextId.WebApiUrl))
if (string.IsNullOrEmpty(webApiUrl))
{
throw new InvalidOperationException("An error occurred trying to obtain the WebApi from the current user's identity claims.");
}

// UserInfo endpoint must support multiple subdomains, i.e. sod, sod1, online, online1, online2, ...
// - subdomain only becomes known from id token
// Example WebApi Url https://sod.superoffice.com/Cust12345/api/
var userInfoEndpoint = string.Format(CultureInfo.InvariantCulture, SuperOfficeAuthenticationConstants.FormatStrings.UserInfoEndpoint, contextId.WebApiUrl);
var userInfoEndpoint = string.Format(CultureInfo.InvariantCulture, SuperOfficeAuthenticationConstants.FormatStrings.UserInfoEndpoint, webApiUrl);

// Get the SuperOffice user principal.
using var request = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint);
Expand Down

0 comments on commit b2f8527

Please sign in to comment.