public IIdentityManagerService Create()
        {
            var db = new IdentityDbContext<IdentityUser>(_connString);
            var userstore = new UserStore<IdentityUser>(db);
            var usermgr = new Microsoft.AspNet.Identity.UserManager<IdentityUser>(userstore);
            usermgr.PasswordValidator = new Microsoft.AspNet.Identity.PasswordValidator
            {
                RequiredLength = 3
            };
            var rolestore = new RoleStore<IdentityRole>(db);
            var rolemgr = new Microsoft.AspNet.Identity.RoleManager<IdentityRole>(rolestore);

            var svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<IdentityUser, string, IdentityRole, string>(usermgr, rolemgr);

            var dispose = new DisposableIdentityManagerService(svc, db);
            return dispose;

            //var db = new CustomDbContext(_connString);
            //var userstore = new CustomUserStore(db);
            //var usermgr = new CustomUserManager(userstore);
            //var rolestore = new CustomRoleStore(db);
            //var rolemgr = new CustomRoleManager(rolestore);

            //var svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<CustomUser, int, CustomRole, int>(usermgr, rolemgr);
            //var dispose = new DisposableIdentityManagerService(svc, db);
            //return dispose;
        }
        public IIdentityManagerService Create()
        {
            var db        = new IdentityDbContext <IdentityUser>(_connString);
            var userstore = new UserStore <IdentityUser>(db);
            var usermgr   = new Microsoft.AspNet.Identity.UserManager <IdentityUser>(userstore);

            usermgr.PasswordValidator = new Microsoft.AspNet.Identity.PasswordValidator
            {
                RequiredLength = 3
            };
            var rolestore = new RoleStore <IdentityRole>(db);
            var rolemgr   = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(rolestore);

            var svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <IdentityUser, string, IdentityRole, string>(usermgr, rolemgr);

            var dispose = new DisposableIdentityManagerService(svc, db);

            return(dispose);

            //var db = new CustomDbContext(_connString);
            //var userstore = new CustomUserStore(db);
            //var usermgr = new CustomUserManager(userstore);
            //var rolestore = new CustomRoleStore(db);
            //var rolemgr = new CustomRoleManager(rolestore);

            //var svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<CustomUser, int, CustomRole, int>(usermgr, rolemgr);
            //var dispose = new DisposableIdentityManagerService(svc, db);
            //return dispose;
        }
Пример #3
0
        public IIdentityManagerService Create()
        {
#if USE_INT_PRIMARYKEY
            var db      = new IdentityDbContext <CustomUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim>(connString);
            var store   = new UserStore <CustomUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim>(db);
            var usermgr = new UserManager <CustomUser, int>(store);
            usermgr.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 3
            };

            var rolestore = new RoleStore <CustomRole, int, CustomUserRole>(db);
            var rolemgr   = new RoleManager <CustomRole, int>(rolestore);

            var svc     = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <CustomUser, int, CustomRole, int>(usermgr, rolemgr);
            var dispose = new DisposableIdentityManagerService(svc, db);
            return(dispose);
#else
            var db        = new IdentityDbContext <IdentityUser>(this.connString);
            var userstore = new UserStore <IdentityUser>(db);
            var usermgr   = new Microsoft.AspNet.Identity.UserManager <IdentityUser>(userstore);
            usermgr.PasswordValidator = new Microsoft.AspNet.Identity.PasswordValidator
            {
                RequiredLength = 3
            };

            var rolestore = new RoleStore <IdentityRole>(db);
            var rolemgr   = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(rolestore);

            var svc     = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <IdentityUser, string, IdentityRole, string>(usermgr, rolemgr);
            var dispose = new DisposableIdentityManagerService(svc, db);
            return(dispose);
#endif
        }
        public IIdentityManagerService Create()
        {
            var db        = new IdentityDbContext <IdentityUser>(this.connString);
            var userStore = new UserStore <IdentityUser>(db);
            var userMgr   = new Microsoft.AspNet.Identity.UserManager <IdentityUser>(userStore);
            var roleStore = new RoleStore <IdentityRole>(db);
            var roleMgr   = new Microsoft.AspNet.Identity.RoleManager <IdentityRole>(roleStore);

            Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <IdentityUser, string, IdentityRole, string> svc = null;
            svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <IdentityUser, string, IdentityRole, string>(userMgr, roleMgr);

            // uncomment to add other properties that are mapped to claims
            //svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<IdentityUser, string, IdentityRole, string>(userMgr, roleMgr, () =>
            //{
            //    var meta = svc.GetStandardMetadata();
            //    meta.UserMetadata.UpdateProperties =
            //        meta.UserMetadata.UpdateProperties.Union(new PropertyMetadata[]{
            //            svc.GetMetadataForClaim(Constants.ClaimTypes.Name, "Name")
            //        });
            //    return Task.FromResult(meta);
            //});

            return(new DisposableIdentityManagerService(svc, db));

            //var db = new CustomDbContext("CustomAspId");
            //var store = new CustomUserStore(db);
            //var mgr = new CustomUserManager(store);
            //return new Thinktecture.IdentityManager.AspNetIdentity.UserManager<CustomUser, int, CustomUserLogin, CustomUserRole, CustomUserClaim>(mgr, db);
        }
        public IIdentityManagerService Create()
        {
            #region MyIdentity Stuff
            MyIdentityDbContext db = new MyIdentityDbContext();
            UserStore<MyIdentityUser> userStore = new UserStore<MyIdentityUser>(db);
            UserManager<MyIdentityUser> userManager = new UserManager<MyIdentityUser>(userStore);

            RoleStore<MyIdentityRole> roleStore = new RoleStore<MyIdentityRole>(db);
            RoleManager<MyIdentityRole> roleManager = new RoleManager<MyIdentityRole>(roleStore);
            #endregion

            var svc = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<MyIdentityUser, string, MyIdentityRole, string>(userManager, roleManager);

            return new DisposableIdentityManagerService(svc, db);
        }
Пример #6
0
        public IIdentityManagerService Create()
        {
            var db      = new IdentityDbContext <AppUser, AppRole, int, AppUserLogin, AppUserRole, AppUserClaim>(connString);
            var store   = new UserStore <AppUser, AppRole, int, AppUserLogin, AppUserRole, AppUserClaim>(db);
            var usermgr = new UserManager <AppUser, int>(store);

            usermgr.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 3
            };

            var rolestore = new RoleStore <AppRole, int, AppUserRole>(db);
            var rolemgr   = new RoleManager <AppRole, int>(rolestore);

            var svc     = new Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService <AppUser, int, AppRole, int>(usermgr, rolemgr);
            var dispose = new DisposableIdentityManagerService(svc, db);

            return(dispose);
        }