asp.net-identity

MVC 5 Identity 2.0 lockout doesn't work

白昼怎懂夜的黑 提交于 2019-12-21 12:24:52
问题 I need to block a user permanently. I don't understand why this code is not working. This line UserManager.IsLockedOut(user.Id); always returns false instead of true . Maybe it's necessary to put this line UserManager.UserLockoutEnabledByDefault = true; in user registration stage? using (var _db = new ApplicationDbContext()) { UserStore<DALApplicationUser> UserStore = new UserStore<DALApplicationUser>(_db); UserManager<DALApplicationUser> UserManager = new UserManager<DALApplicationUser>

How to remove dbo.AspNetUserClaims and dbo.AspNetUserLogins tables (IdentityUserClaim and IdentityUserLogin entities)?

孤人 提交于 2019-12-21 12:17:28
问题 Our application doesn't need the excessive "Logins" and "Claims" functionality that identity uses. It would be nice if these tables simlpy didn't get created in the database, but I don't want to have to reimplement all identity classes... I'd assume it's something like public ApplicationDbContext : IdentityDbContext { [...] protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Ignore<IdentityUserClaim>(); modelBuilder.Ignore

OWIN Cookies vs FormsAuthentication

只谈情不闲聊 提交于 2019-12-21 12:15:14
问题 Are there any major advantages of using OWIN cookie-based authentication over Forms Authentication cookie-based authentication for developing MVC web applications? The reason I ask is that I would not be using any of the Entity Framework based hooks for OWIN authentication. I've built apps based on Forms Authentication for years and have been able to do things like create different authentication tokens for admins (faster timeouts), anonymous users, and registered users. Using the UserData

How to change PasswordValidator in MVC6 or AspNet Core or IdentityCore

丶灬走出姿态 提交于 2019-12-21 10:00:17
问题 In the Asp.Net MVC 5 using Identity, was possible to do the following: manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireLowercase = true, RequireDigit = false, RequireUppercase = false }; How to change the same configuration in MVC 6? I see that can be in ConfigurationServices method in the segment: services.AddIdentity<ApplicationUser, IdentityRole>() .AddPasswordValidator<>() But I could not use. 回答1: The Solution Beta6 In the Startup.cs write the code:

ASP.Net Identity Identity.IsAuthenticated remains true, even after deleting user

北战南征 提交于 2019-12-21 07:55:27
问题 I have implemented ASP.Net Identity after following the sample code here: https://github.com/rustd/AspnetIdentitySample In my implementation I check if a user is authenticated - this is called from a FilterAttribute on my MVC Controllers; the idea is i want to confirm they are still auth'ed before serving up the page. So in my filter, the following code eventually gets called: _authenticationManager.User.Identity.IsAuthenticated; _authenticationManager is here: private IAuthenticationManager

UserManager Error - A second operation started on this context before a previous asynchronous operation completed

ⅰ亾dé卋堺 提交于 2019-12-21 07:38:57
问题 I am facing this issue with my asp.net MVC5 web application, using Identity v2.0.0.0, EF 6, Castle Windsor IOC Container, Microsoft SQL Server 2005 I am trying to get the current logged in User by using UserManagerExtensions,FindById() method but it is throwing an error "System.NotSupportedException : A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method

Issues Configuring StructureMap.MVC5 to work with Identity

折月煮酒 提交于 2019-12-21 05:42:09
问题 I am currently trying to reconfigure StructureMap in our application after upgrading from an old version (2.6) that was never correctly implemented in the first place. I am new to using DI Containers to begin with, and am finding documentation for newer StructureMap versions hard to find. I uninstalled the old 2.6 version of StructureMap and installed StructureMap.MVC5 (since I am using MVC5). What I am having issues with is the AccountController. I have StructureMap set up to use the

How to add a Foreign key in Customer table (CreatedBy column) for AspNetUser table (Id column) in ASP.NET MVC 5 Identity 2.0 using Code First

非 Y 不嫁゛ 提交于 2019-12-21 05:19:04
问题 I have created Empty MVC (ASP.NET Web Application) project using Visual Studio 2013 Update 2 RC & then added AspNet Identity Samples using: PM>Install-Package Microsoft.AspNet.Identity.Samples -Pre I have enabled and added migrations & then updated database, which created default tables. I want to create Customer table which contains 2 columns as Foreign Keys to: Groups table (GroupId column) AspNetUsers table (Id column) So I have created 2 classes Customer & Group and added Foreign Keys

ASP.NET MVC 5 Identity 2.0, Windows Auth, User model with role attribute

做~自己de王妃 提交于 2019-12-21 05:07:09
问题 I'm trying to create an MVC5 application that uses Windows Authentication but uses roles pulled from a User model. I've searched high and low for an example, but the only ones I can find are based on the old ASP.NET identity framework. Anyone care to point me in the right direction?! Thanks! 回答1: So I've figured out one approach to solving this problem. I created a custom Authorization Attribute that checks the User model for a role. using System.Linq; using System.Web; using System.Web.Mvc;

ASP.NET MVC 5 Identity 2.0, Windows Auth, User model with role attribute

天涯浪子 提交于 2019-12-21 05:07:02
问题 I'm trying to create an MVC5 application that uses Windows Authentication but uses roles pulled from a User model. I've searched high and low for an example, but the only ones I can find are based on the old ASP.NET identity framework. Anyone care to point me in the right direction?! Thanks! 回答1: So I've figured out one approach to solving this problem. I created a custom Authorization Attribute that checks the User model for a role. using System.Linq; using System.Web; using System.Web.Mvc;