Browse Source

Adding tenant_id to claims, so that it can be retrieved from HttpContext.User

pull/1240/head
espent1004 5 years ago
parent
commit
069baa2aad
3 changed files with 7 additions and 2 deletions
  1. +5
    -0
      src/Services/Identity/Identity.API/Services/ProfileService.cs
  2. +0
    -1
      src/Web/WebMVC/Controllers/OrderController.cs
  3. +2
    -1
      src/Web/WebMVC/Services/IdentityParser.cs

+ 5
- 0
src/Services/Identity/Identity.API/Services/ProfileService.cs View File

@ -106,6 +106,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
if (!string.IsNullOrWhiteSpace(user.ZipCode))
claims.Add(new Claim("address_zip_code", user.ZipCode));
if (user.TenantId != 0)
{
claims.Add(new Claim("tenant_id", user.TenantId.ToString()));
}
if (_userManager.SupportsUserEmail)
{
claims.AddRange(new[]


+ 0
- 1
src/Web/WebMVC/Controllers/OrderController.cs View File

@ -95,7 +95,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{
var user = _appUserParser.Parse(HttpContext.User);
var vm = await _orderSvc.GetMyOrders(user);
if (user.TenantId == 1)


+ 2
- 1
src/Web/WebMVC/Services/IdentityParser.cs View File

@ -33,7 +33,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
SecurityNumber = claims.Claims.FirstOrDefault(x => x.Type == "card_security_number")?.Value ?? "",
State = claims.Claims.FirstOrDefault(x => x.Type == "address_state")?.Value ?? "",
Street = claims.Claims.FirstOrDefault(x => x.Type == "address_street")?.Value ?? "",
ZipCode = claims.Claims.FirstOrDefault(x => x.Type == "address_zip_code")?.Value ?? ""
ZipCode = claims.Claims.FirstOrDefault(x => x.Type == "address_zip_code")?.Value ?? "",
TenantId = int.Parse(claims.Claims.FirstOrDefault(x => x.Type == "tenant_id")?.Value ?? "0")
};
}
throw new ArgumentException(message: "The principal must be a ClaimsPrincipal", paramName: nameof(principal));


Loading…
Cancel
Save