Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public static async Task<AuthenticateResult> AuthenticateBackOfficeAsync(this Ht
// Otherwise we can't log in as both a member and a backoffice user
// For instance if you've enabled basic auth.
ClaimsPrincipal? authenticatedPrincipal = result.Principal;
IEnumerable<ClaimsIdentity> existingIdentities = httpContext.User.Identities.Where(x => x.IsAuthenticated && x.AuthenticationType != authenticatedPrincipal.Identity.AuthenticationType);

// Make sure to copy into a list before attempting to update the authenticated principal, so we don't attempt to modify
// the collection while iterating it.
// See: https://github.com/umbraco/Umbraco-CMS/issues/18509
var existingIdentities = httpContext.User.Identities
.Where(x => x.IsAuthenticated && x.AuthenticationType != authenticatedPrincipal.Identity.AuthenticationType)
.ToList();
authenticatedPrincipal.AddIdentities(existingIdentities);

httpContext.User = authenticatedPrincipal;
Expand Down
Loading