asp.net-identity

asp.net-identity transaction issue

江枫思渺然 提交于 2019-12-30 21:58:28
问题 I want to create a user with a role in the same transaction but i have an issue with the implementation. In order to use the userStore in the transaction and have it not save the changes automatically and ignore my transaction i had to turn off AutoSaveChanges. This makes it so it will wait until i call save changes. This works fine but because the userstore now does not return the userId when i call manager.Create due to this being off I dont have an Id to pass into userManager.AddToRole. Is

Is there a way to create a custom User and Role without specifying the TKey on IdenitityUser, IdentityRole, and IdentityDbContext?

北城以北 提交于 2019-12-30 11:21:19
问题 Is there a way to create a custom User and Role without specifying the TKey string in IdentityUser , IdentityRole , and IdentityDbContext ? I ask because it seems to think I don't want the auto-generated primary key Id anymore and I absolutely do. Doing what I've done below, UserManager.Create(user, password) will fail with an EntityValidationError on Id . public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { [Required]

Viewing user roles show the role id instead of the role name

天大地大妈咪最大 提交于 2019-12-30 11:07:18
问题 I'm trying to configure role-based authorization in ASP.NET Identity. I want to make it so that Admin users can see a list of users and their roles (on the Index page) and change the roles of individual users (on an Edit page). Here's my context: modelBuilder.Entity<IdentityUser>() .HasKey<string>(k => k.Id) .ToTable("Users"); modelBuilder.Entity<IdentityUserRole>() .HasKey(r => new { r.RoleId, r.UserId }) .ToTable("UserRoles"); modelBuilder.Entity<IdentityUserLogin>() .HasKey<string>(f => f

Viewing user roles show the role id instead of the role name

时光总嘲笑我的痴心妄想 提交于 2019-12-30 11:07:16
问题 I'm trying to configure role-based authorization in ASP.NET Identity. I want to make it so that Admin users can see a list of users and their roles (on the Index page) and change the roles of individual users (on an Edit page). Here's my context: modelBuilder.Entity<IdentityUser>() .HasKey<string>(k => k.Id) .ToTable("Users"); modelBuilder.Entity<IdentityUserRole>() .HasKey(r => new { r.RoleId, r.UserId }) .ToTable("UserRoles"); modelBuilder.Entity<IdentityUserLogin>() .HasKey<string>(f => f

“No IUserTokenProvider is registered” when using structuremap dependency injection

拈花ヽ惹草 提交于 2019-12-30 09:47:29
问题 I have an MVC 5 project that has been modified to use int as the primary key for identity as shown in this guide I then enabled email confirmation as described in this guide Everything worked fine as expected. Then I installed structuremap.mvc5 for dependency injection and added modified DefaultRegistry.cs to public DefaultRegistry() { Scan( scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); scan.AssemblyContainingType(typeof(MyProject.Data.MyDbContext)); scan.With(new

Bad Request (400) when using Web API Token Authentication from Angular JS

痞子三分冷 提交于 2019-12-30 09:37:40
问题 I want to establish Web API Token Authentication with Angular JS as client. I am very new to this concept of Token Authentication inside Web API. I do not want to use ASP.NET Identity default tables to add or authenticate user. I have my own database and a table called "EmployeeAccess" table which contains EmployeeNumber as User Id and Password. I want to authenticate the users against the values in this table and then want to grant token so that they gets authorized for subsequent call. I

Accessing Navigation Properties from IdentityUser when LazyLoading is off

我的未来我决定 提交于 2019-12-30 09:29:15
问题 I've this setup with code first model: public class TestContext :IdentityDbContext<TestUser> { public TestContext() : base("TestConnection") { this.Configuration.LazyLoadingEnabled = false; } public DbSet<Customer> Customers{get;set;} } public class TestUser : IdentityUser { public virtual Customer Customer { get; set; } } public class Customer { public int Id { get; set; } public string FirstName { get; set; } public string LastName {get; set;} } I've extended the IdentityUser to contain an

Cannot access a disposed object Asp.net Identity Core

﹥>﹥吖頭↗ 提交于 2019-12-30 06:21:07
问题 I am getting this error System.ObjectDisposedException HResult=0x80131622 Message=Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take

ASP.NET MVC 5 (VS2013 final): Facebook login with OWIN fails (loginInfo is null)

人盡茶涼 提交于 2019-12-30 06:06:53
问题 I installed the VS2013 final bits that were released yesterday, and I'm trying to get an example working where I enable an external Facebook login. My first question: In this controller code (which I did not touch and left as is from the sample template): // // GET: /Account/ExternalLoginCallback [AllowAnonymous] public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return

How to add custom table in ASP.NET IDENTITY?

痴心易碎 提交于 2019-12-30 06:02:33
问题 I'm using ASP.NET Identity on my web form application. Below is my current identity tables: Current Identity tables - Role - User - UserClaim - UserLogin - UserRole I need to add a new table to store additional information. New Table: UserLogs Fields inside the new table: UserLogID (PK) UserID (FK) IPAddress LoginDate How can I add this custom table? I know how to add custom fields inside existing table but I don't know how to achieve this. I appreciate your efforts in reaching a solution for