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

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

            app.SetBackOfficeUserManagerType <BackOfficeUserManager, BackOfficeIdentityUser>();

            //Create a sign in manager per request
            app.CreatePerOwinContext <BackOfficeSignInManager>((options, context) => BackOfficeSignInManager.Create(options, context, globalSettings, app.CreateLogger(typeof(BackOfficeSignInManager).FullName)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Configure Default Identity User Manager for Umbraco
        /// </summary>
        /// <param name="app"></param>
        /// <param name="services"></param>
        /// <param name="contentSettings"></param>
        /// <param name="globalSettings"></param>
        /// <param name="userMembershipProvider"></param>
        public static void ConfigureUserManagerForUmbracoBackOffice(this IAppBuilder app,
                                                                    ServiceContext services,
                                                                    IContentSection contentSettings,
                                                                    IGlobalSettings globalSettings,
                                                                    MembershipProviderBase userMembershipProvider)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (userMembershipProvider == null)
            {
                throw new ArgumentNullException(nameof(userMembershipProvider));
            }

            //Configure Umbraco user manager to be created per request
            app.CreatePerOwinContext <BackOfficeUserManager>(
                (options, owinContext) => BackOfficeUserManager.Create(
                    options,
                    services.UserService,
                    services.MemberTypeService,
                    services.EntityService,
                    services.ExternalLoginService,
                    userMembershipProvider,
                    contentSettings,
                    globalSettings));

            app.SetBackOfficeUserManagerType <BackOfficeUserManager, BackOfficeIdentityUser>();

            //Create a sign in manager per request
            app.CreatePerOwinContext <BackOfficeSignInManager>((options, context) => BackOfficeSignInManager.Create(options, context, globalSettings, app.CreateLogger <BackOfficeSignInManager>()));
        }
        /// <summary>
        /// Creates a BackOfficeUserManager instance with all default options and the default BackOfficeUserManager
        /// </summary>
        /// <param name="options"></param>
        /// <param name="userService"></param>
        /// <param name="memberTypeService"></param>
        /// <param name="entityService"></param>
        /// <param name="externalLoginService"></param>
        /// <param name="membershipProvider"></param>
        /// <param name="contentSectionConfig"></param>
        /// <param name="globalSettings"></param>
        /// <returns></returns>
        public static BackOfficeUserManager Create(
            IdentityFactoryOptions <BackOfficeUserManager> options,
            IUserService userService,
            IMemberTypeService memberTypeService,
            IEntityService entityService,
            IExternalLoginService externalLoginService,
            MembershipProviderBase membershipProvider,
            IContentSection contentSectionConfig,
            IGlobalSettings globalSettings)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }
            if (memberTypeService == null)
            {
                throw new ArgumentNullException("memberTypeService");
            }
            if (externalLoginService == null)
            {
                throw new ArgumentNullException("externalLoginService");
            }

            var manager = new BackOfficeUserManager(
                new BackOfficeUserStore(userService, memberTypeService, entityService, externalLoginService, globalSettings, membershipProvider));

            manager.InitUserManager(manager, membershipProvider, contentSectionConfig, options);
            return(manager);
        }
 /// <summary>
 /// Initializes the user manager with the correct options
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="membershipProvider"></param>
 /// <param name="contentSectionConfig"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 protected void InitUserManager(
     BackOfficeUserManager manager,
     MembershipProviderBase membershipProvider,
     IContentSection contentSectionConfig,
     IdentityFactoryOptions <BackOfficeUserManager> options)
 {
     //NOTE: This method is mostly here for backwards compat
     base.InitUserManager(manager, membershipProvider, options.DataProtectionProvider, contentSectionConfig);
 }
        /// <summary>
        /// Creates a BackOfficeUserManager instance with all default options and a custom BackOfficeUserManager instance
        /// </summary>
        /// <param name="options"></param>
        /// <param name="customUserStore"></param>
        /// <param name="membershipProvider"></param>
        /// <param name="contentSectionConfig"></param>
        /// <returns></returns>
        public static BackOfficeUserManager Create(
            IdentityFactoryOptions <BackOfficeUserManager> options,
            BackOfficeUserStore customUserStore,
            MembershipProviderBase membershipProvider,
            IContentSection contentSectionConfig)
        {
            var manager = new BackOfficeUserManager(customUserStore, options, membershipProvider, contentSectionConfig);

            return(manager);
        }