From b850cd3ee0551c707da4faef7950df1db9142648 Mon Sep 17 00:00:00 2001 From: Callum Whyte Date: Fri, 13 Oct 2023 13:30:13 +0200 Subject: [PATCH] Add SetMemberSignInManager builder extension (#14761) * Add SetMemberSignInManager builder extension * Added required using statement --------- Co-authored-by: Emma Garland --- .../Extensions/UmbracoApplicationBuilder.Identity.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Identity.cs b/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Identity.cs index ec3f0f5055..0c9f56a010 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Identity.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoApplicationBuilder.Identity.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Umbraco.Cms.Core.DependencyInjection; using Umbraco.Cms.Core.Security; +using Umbraco.Cms.Web.Common.Security; namespace Umbraco.Extensions; @@ -39,6 +40,17 @@ public static partial class UmbracoApplicationBuilderExtensions return builder; } + public static IUmbracoBuilder SetMemberSignInManager(this IUmbracoBuilder builder) + where TSignInManager : SignInManager, IMemberSignInManager + { + Type customType = typeof(TSignInManager); + Type signInManagerType = typeof(SignInManager); + builder.Services.Replace(ServiceDescriptor.Scoped(typeof(IMemberSignInManager), customType)); + builder.Services.AddScoped(customType, services => services.GetRequiredService(signInManagerType)); + builder.Services.Replace(ServiceDescriptor.Scoped(signInManagerType, customType)); + return builder; + } + public static IUmbracoBuilder SetMemberUserStore(this IUmbracoBuilder builder) where TUserStore : MemberUserStore {