mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
parent
6f95b20b48
commit
49b2a0f0ce
@ -1,6 +1,6 @@
|
|||||||
namespace Ocelot.Infrastructure.Claims.Parser
|
namespace Ocelot.Infrastructure.Claims.Parser
|
||||||
{
|
{
|
||||||
using Errors;
|
using Microsoft.Extensions.Primitives;
|
||||||
using Responses;
|
using Responses;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -45,11 +45,11 @@
|
|||||||
|
|
||||||
private Response<string> GetValue(IEnumerable<Claim> claims, string key)
|
private Response<string> GetValue(IEnumerable<Claim> claims, string key)
|
||||||
{
|
{
|
||||||
var claim = claims.FirstOrDefault(c => c.Type == key);
|
var claimValues = claims.Where(c => c.Type == key).Select(c => c.Value).ToArray();
|
||||||
|
|
||||||
if (claim != null)
|
if (claimValues.Length > 0)
|
||||||
{
|
{
|
||||||
return new OkResponse<string>(claim.Value);
|
return new OkResponse<string>(new StringValues(claimValues).ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ErrorResponse<string>(new CannotFindClaimError($"Cannot find claim for key: {key}"));
|
return new ErrorResponse<string>(new CannotFindClaimError($"Cannot find claim for key: {key}"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user