asp.net-identity-2

Creating Users with No Password using ASP.NET Identity

我的梦境 提交于 2019-11-29 13:28:43
问题 I have been given the requirement to provide the ability to create users through the UI with no password. I am trying to accomplish this using ASP.NET Identity. I am able to successfully create a user without a password using the UserManager's Create method: if (vm.ShouldHavePassword) { userManager.Create(userToInsert, vm.Password); } else { userManager.Create(userToInsert); } After the call to the Create method, the test user gets successfully saved into our AspNetUsers table. And when I do

Add user First Name and Last Name to an ASP.NET Identity 2?

我与影子孤独终老i 提交于 2019-11-29 12:40:58
问题 I changed over to use the new ASP.NET Identity 2. I'm actually using the Microsoft ASP.NET Identity Samples 2.0.0-beta2. Can anyone tell me where and how I can modify the code so that it stores a user First and Last name along with the user details. Would this now be part of a claim and if so how could I add it ? I assume I would need to add this here which is the register method in the account controller: if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email,

ASP MVC Build Throwing Warning For ApplicationUser Roles Navigation Property?

Deadly 提交于 2019-11-29 12:13:37
I have the following ApplicationUser Model: public class ApplicationUser : IdentityUser { public string FirstName { get; set; } public string LastName { get; set; } public virtual ICollection<ApplicationRole> Roles { get; set; } public bool HasRole(string _role) { return Roles.Any(r => r.Name == _role); } public bool HasPermission(string _permission) { return Roles.Any(r => r.Permissions .Any(p => p.Name == _permission)); } } But when I run a build I get the following warning message: ApplicationUser.Roles hides inherited member 'IdentityUser<string, IdentityUserLogin,IdentityUserRole,

Transforming / Modifying claims in asp.net identity 2

佐手、 提交于 2019-11-29 12:00:40
In Windows Identity Framework (WIF) you could implement a ClaimsAuthenticationManager in order to modify the claims on the principal or add new claims to it. The claims authentication manager provides an extensibility point in the application’s claims processing pipeline that you can use to validate, filter, modify, incoming claims or inject new claims into the set of claims presented by a ClaimsPrincipal before the RP application code is executed. Does ASP.net Identity 2 have any sort of pipeline hook like this? If I want to add some claims without having them persisted in the

Custom email confirmation token

百般思念 提交于 2019-11-29 10:12:14
I'm using the Identity 2.0 framework for user management. Unfortunately, in my use case an account activation/password reset cannot be done using a direct link, so the user would have to copy the code from his e-mail and paste it into the website. The code that is generated by the UserManager 's default GenerateEmailConfirmationTokenAsync method is very long, it spans about 3 lines of text. I tried to override this method, generating a shorter code that is more user friendly. This doesn't work, as the ConfirmEmailAsync method always returns "invalid token" (this method doesn't call the

asp.net core identity extract and save external login tokens and add claims to local identity

你。 提交于 2019-11-29 09:27:30
问题 I am a stackoverflow noob so please go easy if I am doing this wrong. I am using asp.net core with the default core identity template (local accounts). I have accertained how to add claims to user principal when they login locally like so [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<IActionResult> Login(LoginInputModel model) { if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account

ASP Identity 2.0: Regenerate Identity

喜夏-厌秋 提交于 2019-11-29 03:26:11
问题 I am having trouble getting ASP Identity to refresh its Identity stored in a cookie on demand. In the Startup.Auth.cs file the cookie is set to regenerate as follows: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<QuizSparkUserManager, QuizSparkUser, int>(

Suppress redirect on API URLs in ASP.NET Core

南楼画角 提交于 2019-11-29 01:50:06
I have an ASP.NET Core site that uses cookie authentication for most pages. For those pages, the default server response of providing a 302 redirect for an unauthorized client is desirable. However, the site also accepts API requests; they use API keys and have no use for cookies. Ideally, I'd like to turn off cookie processing for the API URLs altogether, but minimally, I need to ensure that if an API client is unauthorized, the server doesn't respond with a 302 redirect. Replace the redirect event handler with one that uses the default behavior only if the path is not an API. In Startup

Entity Framework 6 and Asp.Net Identity UserManager: Multiple DbContext

。_饼干妹妹 提交于 2019-11-29 00:28:27
This is MVC 5/ EF6. So I have the following classes: public class User : IdentityUser { public User() { Levels = new List<Level>(); } [Required, MaxLength(200)] public string FirstName { get; set; } [Required, MaxLength(200)] public string LastName { get; set; } public virtual ICollection<Level> Levels { get; set; } } and public class Level { public int Id { get; set; } [Required] public string Name { get; set; } public virtual ICollection<User> Users { get; set; } } In addition to regular MVC5 membership tables it creates 2 more: Levels and UserLevels (with User_Id and Level_Id columns).

How To Change Password Validation in ASP.Net MVC Identity 2?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 17:09:38
How To Change Password Validation in ASP.Net MVC5 Identity 2 ? Thanks In the MVC project template in VS2013 Update 2, there should be a file called App_Start/IdentityConfig.cs . In it you should find the class ApplicationUserManager and a static factory method called Create() . That's where the user manager class is configured, including the server-side validation rules for passwords are defined. For example: manager.PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, }; In