asp.net-identity

ASP.NET Identity - Error when changing User ID Primary Key default type from string to int AND when using custom table names

若如初见. 提交于 2019-12-03 13:39:29
I'm using Microsoft.AspNet.Identity 2.0.0-beta1 and Entity Framework 6.1.0-beta1 (released 11 Feb 2014). I'm getting the following error when I try to change the default type of User ID Primary Key from string to int AND when I try to use custom table names (so User.MyUsers instead of dbo.AspNetUsers): " The entity types 'IdentityUser' and 'ApplicationUser' cannot share table 'MyUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship with matching primary keys between them. " I can successfully change the default type of User ID PK from

Asp.net Identity 2.0 - Unique Email

自古美人都是妖i 提交于 2019-12-03 13:35:57
My application is MVC5, I tried to allow duplicate email address using the following: public async Task<ActionResult> AddUser (UserRegisterViewModel userViewModel) { ...... if (ModelState.IsValid) { var user = new ApplicationUser { ...... }; var adminresult = await UserManager.CreateAsync(user); var result = await UserManager.AddToRolesAsync(user.Id, user.Profession); UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) { RequireUniqueEmail = false }; if (adminresult.Succeeded) { .... return RedirectToAction("VisitInfo", "Visit"); } if (!adminresult.Succeeded) { var er =

How to hold the cookies claims updated with MCV5/OWIN

浪子不回头ぞ 提交于 2019-12-03 13:23:30
We’re working on an OWIN MVC5 project. We use an own implementation of IUserStore<T> to integrate the user-management which is part of our companies framework. So far this works fine. We want to provide role membership and other security configuration through claims. I have seen (and quickly tested) the ways of either implementing IUserClaimStore<T> or of attaching a ClaimsIdentityFactory to the UserManager. In both scenarios, I see the issue that the claims are stored in the user’s cookie and when a role or another claim changes behind the web app (through another application which directly

How to disable a User in Identity 2.0?

不想你离开。 提交于 2019-12-03 13:17:09
问题 I'm trying to find a way to disable a user in Identity 2.0 and can't seem to find any info on it. I would like to basically set a user to IsActive=false and would prefer to do it as soon as the user is created. However, I need a way to set the IsActive for our site Admin. I already have this with ASP.Net membership but I'm looking to covert the site to MVC and Identity. For my requirements we ask people to go ahead and register an account but we want it to be disabled by default. Then when we

How to implement two factor auth in Web API 2 using ASP.NET identity?

别来无恙 提交于 2019-12-03 12:57:20
I have seen this link Two Factor Auth using goolgle authenticator on how to create a two factor authentication in web api, but my requirements are little different. I want to use two factor authentication for issuing an access token. (If the user has chosen to enable two factor authentication) I would like to create the OTP code using ASP.NET identity itself. (Like the way we do in MVC web application SignInManager.SendTwoFactorCodeAsync("Phone Code") The problem with my current implementation is, when I call SignInManager.SendTwoFactorCodeAsync("Phone Code") I get the error user id not found.

ASP.Net Identity 2 Reset password with SMS

核能气质少年 提交于 2019-12-03 12:55:05
I'm looking to send the user an SMS when reseting their password. I already have the facilities to send a SMS, I just need a guide on how to set it up with Identity 2.0. I can't seem to find any useful info online, the reference code itself isn't properly commented either. I want to generate a security code, send it to the user, he must then input it into a form and then be allowed to reset his/her password. Can anyone direct me to a guide/tutorial that explains this process? After digging in the identity source code i found an alternative token provider that can generate tokens similar to

How to implement a TokenProvider in ASP.NET Identity 1.1 nightly build?

五迷三道 提交于 2019-12-03 12:49:30
问题 I'm trying to implement password reset functionality with nightly build of ASP.NET Identity 1.1. There is a UserManager.GetPasswordResetToken method, but it throws an exception "No ITokenProvider is registered". Is there an built in token provider in ASP.NET Identity? If yes, how I can register it? If no, how I can implement one? Will be default Token Provider in the 1.1. release? And final question, is there an estimated 1.1 release date? 回答1: The default token provider implementation is

using IOC container with IdentityFactory Middleware

穿精又带淫゛_ 提交于 2019-12-03 12:46:39
I am trying to understand the UserManagerFactory middleware explained here per request lifetime management for usermanager . I created this class which I am calling from the Startup Configuration method public class CustomUserManagerProvider { public static CustomUserStore<CustomUser> CreateCustomUserStore() { return new CustomUserStore<CustomUser>(/*Need to inject dependencies here*/); } public static CustomUserManager CreateCustomUserManager(IdentityFactoryOptions<CustomUserManager> options, IOwinContext context) { return new CustomUserManager(context.Get<CustomUserStore<CustomUser>>()); } }

How to invalidate .AspNet.ApplicationCookie after Adding user to Role using Asp.Net Identity 2?

我与影子孤独终老i 提交于 2019-12-03 12:21:14
I have 2 questions related to that: 1) I need to invalidate.AspNet.ApplicationCookie after Adding / Removing some remote user to Role using Asp.Net Identity 2. I Tried to use UpdateSecurityStamp, but since no password or username is changed, SecurityStamp remains same. When I use ApplicationRoleManger I can see that User roles are updated but in User.Identity Claims they stay unchanged. 2) How does .AspNet.ApplicationCookie Validation work and how can I access it? I was trying to use this code, but with no effect What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface? Update: This

Use a Identity 2.0 Database to Authenticate a ASP.NET Core 1.0 application

不羁岁月 提交于 2019-12-03 12:10:34
问题 I am trying to a create a new ASP.NET Core 1.0 web application and I want it to use the Authentication tables that I already have set up. These tables were originally created by a ASP.NET 4.6 web application that used Microsoft.ASPNet.Identity.EntityFramework 2.2.0 It looks like things have change in Microsoft.AspNetCore.Identity.EntityFrameworkCore because the new Core 1.0 application throws this error when trying to log in: A database operation failed while processing the request.