asp.net-identity

Change email workflow in ASP.NET Core

佐手、 提交于 2019-12-11 14:54:40
问题 If a user wants to change to a new email address, I use: var token = await _userManager.GenerateChangeEmailTokenAsync(user, newEmail); ...and send a confirmation mail which includes this change token. The user clicks the link in the email, arrives back at the site, and now I need to change the email. BUT, I don't know the new email address. I've gone through the hassle of an confirmation mail loop, so I want to use it. Asking for the email again risks mistypings that could lock out the user

How to check user role in MVC 5 identity?

一世执手 提交于 2019-12-11 13:33:52
问题 I create a EF code first database identity system with custom roles. When i register a user i put him in a role, and in the database i can see that works on the AspNetUserRoles table. But when i try to check the user role using User.IsInRole("admin") i.e, it always return false( i tried with low, upper, all the way case). I need to put something in the webconfig? Or what im missing here? Its my first time developing with this new Identity system and i think that is a bit confuse. In my

Authentication using Database Logins

橙三吉。 提交于 2019-12-11 13:28:04
问题 I'm somewhat new to ASP.NET MVC and I hoped you can help me with authentication for my app. I have a MVC application that needs to be authenticated using SQL Server Log Ins. This means I have to create roles and users in SQL Server, and all security permissions are managed at Database level. Roles, users, and permissions aren't constant and we should be able to manage them. Any suggestion? Is there anyway to override default behaviors of Identity to achieve this goal? What do you think is the

Using Foreign Keys with different Contexts using Entity Framework code-first

雨燕双飞 提交于 2019-12-11 12:35:09
问题 I have a brand-new ASP.NET MVC 5 project with one DbContext using Entity Framework 6.1 and Identity 2.2.1. Trying go use IoC, I created a 2nd DbContext and some classes belonging to that 2nd context. Most of these classes have a foreign key to the IdentityUser class within Identity 2.2.1. The problem I'm having is that when I try to use Add-Migrations I get the following error: One or more validation errors were detected during model generation: {MyProjectName}.DataContexts.IdentityUserLogin:

None of the constructors found can be invoked with the available services and parameters Autofac

丶灬走出姿态 提交于 2019-12-11 12:15:08
问题 I have read and coding follow example: http://timschreiber.com/2015/01/14/persistence-ignorant-asp-net-identity-with-patterns-part-1/ But that example used Unity for DI, but i'm used Autofac for ID, when i try run my project i have the following error: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'App.Front.Controllers.HomeController' can be invoked with the available services and parameters: Cannot resolve parameter 'Microsoft

Change seed method for an existing Asp.Net MVC 5 (Identity 2) application?

两盒软妹~` 提交于 2019-12-11 12:02:13
问题 How to add a fixed role (e.g. Admin) to an existing Asp.Net Mvc/Identity 2 site? In the link http://bitoftech.net/2015/03/11/asp-net-identity-2-1-roles-based-authorization-authentication-asp-net-web-api/, there are the following code which is exactly what I want to do. However, will the Seed function be executed since the application? (I already have some code, var lookup1 = new List<L1>{new L1 {...},...}; tableL1.ForEach(l => context.tableL1.AddOrUpdate(p=>p.Title, l)); context.SaveChanges()

Custom ASPNET Identity one to many relationship using multiple context application

左心房为你撑大大i 提交于 2019-12-11 11:57:39
问题 Basically, I want to have a user that can create their own stories. I have these classes: public class ApplicationUser : IdentityUser { public string DisplayedName { get; set; } } public class Story { public int Id { get; set; } public string Content { get; set; } } They are managed on a different context and so as their migration. Something like this. public class MyDbContext : DbContext { public DbSet<Story> Stories { get; set; } } public class IdentityContext : IdentityDbContext

IdentityServer, Claims and Roles

一曲冷凌霜 提交于 2019-12-11 11:32:51
问题 I'm playing with Identity Server v4 (but I thinks is the same with v3) and .NET Core. Right now I've strange issue that I don't understand. From my MVC application I use the [Authorize(Roles="Geek")] to protect my controllers/actions. Looking the current User from the HttpContext all the Roles are available as Claims and not as Roles (in fact User.IsInRole("Geek") return false). Moreover I can't use the Claims with the authorize attribute because all role are stored into the claims collection

Why is there an implementation difference between the UserStore and the RoleStore?

柔情痞子 提交于 2019-12-11 11:13:51
问题 This has no problems: public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public ApplicationUserStore(MyAppDb context) : base(context) { } } While this: public class ApplicationRoleStore : RoleStore<ApplicationRole, string, ApplicationUserRole> { public ApplicationRoleStore(MyAppDb context) : base(context) { } } ...produces the following compile time error: The type 'MyApp.Models