asp.net-identity

Use the same database for both my custom entities and identity context?

≡放荡痞女 提交于 2019-12-04 20:48:49
问题 I want to make an MVC website with user logins/authentication etc. I'm using EF CodeFirst to create my database. If I create a new MVC project and select Authentication: Individual User Accounts, it will create a new project with an already existing IdentityDbContext etc. Am I meant to continue using this along with my own DbContext? One context for my projects entities, and the other context for the Identity entities? Does this mean I'll have two separate databases, or can I give them both

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

两盒软妹~` 提交于 2019-12-04 20:40:41
问题 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

Implementing custom claim with extended MVC Core Identity user

痴心易碎 提交于 2019-12-04 20:38:51
问题 How can I create a custom authorize claim in MVC Core 2.0 (using AspNetCore.identity) to verify a custom user boolean property? I have extended the IdentityUser (ApplicationUser) to include a boolean value "IsDeveloper". I am using claims based authentication and would like to add a custom claim, but am not certain where to start. How can I create a custom claim that will: Find the current (customized) Core.Identity user. Evaluate the a custom identity user bool value? I understand the core

Identity UserManager.AddToRole throws exception

折月煮酒 提交于 2019-12-04 19:54:57
As the title says I am using the new C# MVC 5 Identity doing a simple call: UserManager.AddToRole(User.Id, User.RequestedRole); I am doing this in a method of my ViewModel that is called from the Controller The UserManager is created in the Base Class of my ViewModel like this: UserManager = new UserManager<TMUser>(new UserStore<TMUser>(new TMContext())); When I make the above call to AddToRole method, I get this Inner Exception (The outer one is generic/useless): {"A relationship from the 'Ledger_User' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding

ASP.Net Identity 2 Reset password with SMS

↘锁芯ラ 提交于 2019-12-04 19:38:48
问题 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? 回答1: After

MVC5 Identity/OWIN - Signout events

蓝咒 提交于 2019-12-04 19:29:53
How to detect all possible SignOuts? Is there a way to get some event when SignOut is made manually, by timeout and any other possible ways? I need to know when user authentication ends like i know that it starts when SingIn is called. I'm using both internal accounts and external (like Facebook). I need a spot that i can initialize user session when user is already authenticated. Below is code that should do the job, i don't like it at all. I need to check session at each request to be sure that flag in session is already loaded and was loaded for current user. In future that flag will be

Asp.Net Identity and multiple login mechanisms

大城市里の小女人 提交于 2019-12-04 19:19:53
I'd like to create an application that would be as open as possible to different login mechanisms. So I've used Asp.Net Identity. For (almost) free, this system gives me: Simple accounts OpenID with Facebook, Microsoft, Google and more If you use the other templates, you can also have Organisational Accounts with the following 3 options: Cloud - Single Organisation Cloud - Multiple Organisations On-Premises My use cases are showing that I need a mix of all of that: Users that want a simple account Users that want to connect with OpenID Companies that are using Office 365 and would like to SSO

Name cannot be null or empty. asp.net identity mvc 5 + EntityFreamwork

混江龙づ霸主 提交于 2019-12-04 19:17:41
问题 Has anyone had a problem with this. He throws me the error: Name can not be null or empty. But in the table do not have the attribute called "Name". I want to customize Asp.Net Identity. Controller public class HomeController : Controller { // // GET: /Home/ public async Task<ActionResult> Index() { var userStore = new UserStore<User,Identity_2Context.MyRole,long,Identity_2Context.MyUserLogin,Identity_2Context.MyUserRole,Identity_2Context.MyClaim>(new Identity_2Context()); var manager = new

How do I initially setup roles and users (like a site admin) with ASP.NET MVC Core? [closed]

旧时模样 提交于 2019-12-04 18:59:59
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 2 years ago . While there seems to be a lot of documentation about verifying roles, claims, etc with ASP.NET Core, there is little information about initially setting these things up in my app. The best way to configure roles, claims, etc, is in your app startup. The new ASP.NET Core Dependency Injection makes setting this up a breeze if you know what you're doing. Most of your work will

asp Identity 2.0 adding new roles and adding user to roles

微笑、不失礼 提交于 2019-12-04 18:25:04
问题 I'm having trouble understanding the new Identity stuff. I'm trying to figure out how to add new roles and add user's to those roles. I'm trying to create a role management page and a user management page for my application and need to be able to do those two things. Everytime i try to add a role to a user like this: System.Web.Security.Roles.AddUserToRole("Andy", "admin"); I get "The Role Manager feature has not been enabled." I don't have a custom role provider and i tried turning role