Modified ClaimNameAttribute to support multiple claim names depending on environment
All checks were successful
ci/woodpecker/tag/api_build Pipeline was successful
ci/woodpecker/tag/api_uploadimage Pipeline was successful

Environment name will be pulled from environment variable: ASPNETCORE_ENVIRONMENT
This commit is contained in:
2024-04-07 20:18:53 -05:00
parent 822a8379aa
commit 9fae3b978f
6 changed files with 27 additions and 13 deletions

View File

@ -2,6 +2,7 @@
using YABA.API.Extensions;
using YABA.Common.Extensions;
using YABA.Common.Lookups;
using YABA.Common.Utils;
using YABA.Service.Interfaces;
namespace YABA.API.Middlewares
@ -31,7 +32,7 @@ namespace YABA.API.Middlewares
userId = registedUser.Id;
}
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(), userId.ToString()));
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(EnvironmentUtils.IsDevelopmentEnvironment()), userId.ToString()));
}
}