Updating Claims Identity Value without logging out
When I update a Claims identity value, it updates in the database, but in order to show the new value in the application, I have to log out and log back in. I know it’s a cookie issue, but I need it to show the new value by doing a page refresh and not by logging out and back in.
public async Task<ItemResponse<UpdateIsAutoResponse>> UpdateIsAutoRenew(UpdateIsAutoRenew request)
{
StripeConfiguration.ApiKey = ApiKey;
ItemResponse<UpdateIsAutoResponse> response = new ItemResponse<UpdateIsAutoResponse>();
try
{
if (request.IsAutoRenew == "false")
{
var options = new SubscriptionUpdateOptions
{
PauseCollection = new SubscriptionPauseCollectionOptions
{
Behavior = "void",
},
};
var service = new SubscriptionService();
service.Update(request.SubscriptionId, options);
}
else
{
var options = new SubscriptionUpdateOptions();
options.AddExtraParam("pause_collection", "");
var service = new SubscriptionService();
service.Update(request.SubscriptionId, options);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "PauseSubscription", request);
}
// update autorenew flag
await _userClaimData.Update(new UserClaimsDTO()
{
UserID = Convert.ToInt32(request.UserID),
ClaimType = IsAutoRenew,
ClaimValue = request.IsAutoRenew
});
return response;
}
This is my Update Flag code (API CODE)
var UserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
if (User.Identity.IsAuthenticated)
{
ClaimsPrincipal cp = this.User;
var data = cp.Identities.ToList();
customerId = data[0].FindFirst(c => c.Type == "CustomerIdentifier").Value;
planStatus = data[0].FindFirst(c => c.Type == "TrialStatus").Value;
if (data[0].FindFirst(c => c.Type == "SubscriptionID") != null)
{
SubscriptionID = data[0].FindFirst(c => c.Type == "SubscriptionID").Value;
}
if (data[0].FindFirst(c => c.Type == "IsAutoRenew") != null)
{
IsAutoRenew = data[0].FindFirst(c => c.Type == "IsAutoRenew").Value;
}
}
Note My api code different project and UI Code other project