Ejemplo n.º 1
0
        /// <summary>
        /// Configure a custom UserStore with the Identity User Manager for Umbraco
        /// </summary>
        /// <param name="app"></param>
        /// <param name="appContext"></param>
        /// <param name="userMembershipProvider"></param>
        /// <param name="customUserStore"></param>
        public static void ConfigureUserManagerForUmbracoBackOffice(this IAppBuilder app,
                                                                    ApplicationContext appContext,
                                                                    MembershipProviderBase userMembershipProvider,
                                                                    BackOfficeUserStore customUserStore)
        {
            if (appContext == null)
            {
                throw new ArgumentNullException("appContext");
            }
            if (userMembershipProvider == null)
            {
                throw new ArgumentNullException("userMembershipProvider");
            }
            if (customUserStore == null)
            {
                throw new ArgumentNullException("customUserStore");
            }

            //Configure Umbraco user manager to be created per request
            app.CreatePerOwinContext <BackOfficeUserManager>(
                (options, owinContext) => BackOfficeUserManager.Create(
                    options,
                    customUserStore,
                    userMembershipProvider));

            //Create a sign in manager per request
            app.CreatePerOwinContext <BackOfficeSignInManager>((options, context) => BackOfficeSignInManager.Create(options, context, app.CreateLogger(typeof(BackOfficeSignInManager).FullName)));
        }
        /// <summary>
        /// Configure Default Identity User Manager for Umbraco
        /// </summary>
        /// <param name="app"></param>
        /// <param name="appContext"></param>
        /// <param name="userMembershipProvider"></param>
        public static void ConfigureUserManagerForUmbracoBackOffice(this IAppBuilder app,
                                                                    ApplicationContext appContext,
                                                                    MembershipProviderBase userMembershipProvider)
        {
            if (appContext == null)
            {
                throw new ArgumentNullException("appContext");
            }
            if (userMembershipProvider == null)
            {
                throw new ArgumentNullException("userMembershipProvider");
            }

            //Configure Umbraco user manager to be created per request
            app.CreatePerOwinContext <BackOfficeUserManager>(
                (options, owinContext) => BackOfficeUserManager.Create(
                    options,
                    appContext.Services.UserService,
                    appContext.Services.EntityService,
                    appContext.Services.ExternalLoginService,
                    userMembershipProvider,
                    UmbracoConfig.For.UmbracoSettings().Content));

            app.SetBackOfficeUserManagerType <BackOfficeUserManager, BackOfficeIdentityUser>();

            //Create a sign in manager per request
            app.CreatePerOwinContext <BackOfficeSignInManager>((options, context) => BackOfficeSignInManager.Create(options, context, app.CreateLogger <BackOfficeSignInManager>()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Configure a custom BackOfficeUserManager for Umbraco
        /// </summary>
        /// <param name="app"></param>
        /// <param name="appContext"></param>
        /// <param name="userManager"></param>
        public static void ConfigureUserManagerForUmbracoBackOffice <TManager, TUser>(this IAppBuilder app,
                                                                                      ApplicationContext appContext,
                                                                                      Func <IdentityFactoryOptions <TManager>, IOwinContext, TManager> userManager)
            where TManager : BackOfficeUserManager <TUser>
            where TUser : BackOfficeIdentityUser
        {
            if (appContext == null)
            {
                throw new ArgumentNullException("appContext");
            }
            if (userManager == null)
            {
                throw new ArgumentNullException("userManager");
            }

            //Configure Umbraco user manager to be created per request
            app.CreatePerOwinContext <TManager>(userManager);

            //Create a sign in manager per request
            app.CreatePerOwinContext <BackOfficeSignInManager>((options, context) => BackOfficeSignInManager.Create(options, context, app.CreateLogger(typeof(BackOfficeSignInManager).FullName)));
        }