Created
November 29, 2022 19:38
-
-
Save michaellwest/0a3e8aa2e86e149887eefd19a85aa83f to your computer and use it in GitHub Desktop.
Replace the Sitecore 10.2.1 cumulative hotfix implementation with what was originally provided in 10.2.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.AspNet.Identity; | |
| using Sitecore.Diagnostics; | |
| using Sitecore.Owin.Authentication.Extensions; | |
| using Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.SignIn; | |
| using Sitecore.Owin.Authentication.Services; | |
| using Sitecore.Security.Accounts; | |
| using System.Security.Claims; | |
| namespace Scms.Feature.Security.Pipelines.CookieAuthentication.SignIn | |
| { | |
| public class ResolveUser : SignInProcessor | |
| { | |
| protected ApplicationUserFactory ApplicationUserFactory | |
| { | |
| get; | |
| } | |
| protected UserFactory UserFactory | |
| { | |
| get; | |
| } | |
| public ResolveUser(ApplicationUserFactory applicationUserFactory, UserFactory userFactory) | |
| { | |
| Assert.ArgumentNotNull(applicationUserFactory, "applicationUserFactory"); | |
| Assert.ArgumentNotNull(userFactory, "userFactory"); | |
| this.ApplicationUserFactory = applicationUserFactory; | |
| this.UserFactory = userFactory; | |
| } | |
| public override void Process(SignInArgs args) | |
| { | |
| string name; | |
| Assert.ArgumentNotNull(args, "args"); | |
| ClaimsIdentity identity = args.Context.Identity; | |
| if (identity != null) | |
| { | |
| name = identity.Name; | |
| } | |
| else | |
| { | |
| name = null; | |
| } | |
| string str = name; | |
| if (!string.IsNullOrEmpty(str) && args.Context.OwinContext.GetUserManager().FindByName(str) != null) | |
| { | |
| User user = this.UserFactory.CreateUser(new ClaimsPrincipal(args.Context.Identity)); | |
| args.User = this.ApplicationUserFactory.CreateUser(user); | |
| } | |
| if (args.User == null) | |
| { | |
| args.Success = false; | |
| args.AbortPipeline(); | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/"> | |
| <sitecore role:require="Standalone or ContentManagement"> | |
| <pipelines> | |
| <owin.cookieAuthentication.signIn> | |
| <processor patch:instead="processor[@type='Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.SignIn.ResolveUser, Sitecore.Owin.Authentication']" type="Scms.Feature.Security.Pipelines.CookieAuthentication.SignIn.ResolveUser,Scms.Feature" resolve="true"/> | |
| </owin.cookieAuthentication.signIn> | |
| </pipelines> | |
| </sitecore> | |
| </configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment