示例#1
0
 public AccountController()
 {
     IdentityStore         = new IdentityStoreManager(new IdentityStoreContext());
     AuthenticationManager = new IdentityAuthenticationManager(IdentityStore);
     Bearer = IdentityConfig.Bearer;
     ExternalTokenHandler = new ExternalAccessTokenHandler(IdentityConfig.Bearer.AccessTokenHandler);
 }
 public ActionResult Create(Members Member)
 {
     IdentityStoreManager.AddIdentityUser(Member.EmailAddress, "Passw0rd123*");
     unitOfWork.Members.Add(Member);
     unitOfWork.SaveChanges();
     return(View());
 }
示例#3
0
 public AccountController(IdentityStoreManager identityStore,
                          IdentityAuthenticationManager authenticationManager, OAuthBearerAuthenticationOptions bearer,
                          ISecureDataHandler <ExternalAccessToken> externalTokenHandler)
 {
     IdentityStore         = identityStore;
     AuthenticationManager = authenticationManager;
     Bearer = bearer;
     ExternalTokenHandler = externalTokenHandler;
 }
示例#4
0
        public async static Task <bool> InitAppRoles(IdentityStoreManager identityStore)
        {
            if (!(await identityStore.Context.Roles.RoleExists(ADMIN_ROLE)))
            {
                await identityStore.Context.Roles.CreateRole(new Role(ADMIN_ROLE));
            }
            if (!(await identityStore.Context.Roles.RoleExists(COMPANY_ROLE)))
            {
                await identityStore.Context.Roles.CreateRole(new Role(COMPANY_ROLE));
            }

            await identityStore.Context.SaveChanges();

            return(true);
        }
示例#5
0
        async public Task <ActionResult> Index()
        {
            var result = User.IsInRole("Admin");


            var a             = new IdentityStoreContext(new SiteCertDbContext());
            var identityStore = new IdentityStoreManager(new IdentityStoreContext(new SiteCertDbContext()));

            var x = await a.Roles.IsUserInRole("Admin", "Admin");

            //result = ctx.Roles.IsUserInRole("Admin", "Admin");



            return(View());
        }
示例#6
0
 protected void CreateUser_Click(object sender, EventArgs e)
 {
     string userName = UserName.Text;
     try
     {
         var store = new IdentityStoreManager();
         var storeManager = new IdentityStoreManagerSync(store);
         var authManager = new IdentityAuthenticationManagerSync(new IdentityAuthenticationManager(store));
         User u = new User(userName) { UserName = userName };
         if (storeManager.CreateLocalUser(u, Password.Text))
         {
             authManager.SignIn(new HttpContextWrapper(Context), u.Id, isPersistent: false);
             IdentityConfig.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
         }
     }
     catch (IdentityException ex)
     {
         ErrorMessage.Text = ex.Message;
     }
 }
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            string userName = UserName.Text;

            try
            {
                var  store        = new IdentityStoreManager();
                var  storeManager = new IdentityStoreManagerSync(store);
                var  authManager  = new IdentityAuthenticationManagerSync(new IdentityAuthenticationManager(store));
                User u            = new User(userName)
                {
                    UserName = userName
                };
                if (storeManager.CreateLocalUser(u, Password.Text))
                {
                    authManager.SignIn(new HttpContextWrapper(Context), u.Id, isPersistent: false);
                    IdentityConfig.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                }
            }
            catch (IdentityException ex)
            {
                ErrorMessage.Text = ex.Message;
            }
        }
示例#8
0
 public AccountController(IdentityStoreManager storeManager, IdentityAuthenticationManager authManager)
 {
     IdentityStore = storeManager;
     AuthenticationManager = authManager;
 }
示例#9
0
 public AccountController() 
 {
     IdentityStore = new IdentityStoreManager();
     AuthenticationManager = new IdentityAuthenticationManager(IdentityStore);
 }
 public AccountController(IdentityStoreManager storeManager, IdentityAuthenticationManager authManager)
 {
     IdentityStore         = storeManager;
     AuthenticationManager = authManager;
 }
 public AccountController()
 {
     IdentityStore         = new IdentityStoreManager();
     AuthenticationManager = new IdentityAuthenticationManager(IdentityStore);
 }
示例#12
0
 public AccountController()
 {
     IdentityStore         = new IdentityStoreManager(new IdentityStoreContext(new SiteCertDbContext()));
     AuthenticationManager = new IdentityAuthenticationManager(IdentityStore);
 }