asp.net-identity-2

How to configure ASP.NET Identity ApplicationUserManager with StructureMap

天涯浪子 提交于 2019-11-30 13:01:50
I am using asp.net identity in my project and using structuremap as DI framework. the problem is when i use constructor injection then ApplicationUserManager not configured all of it's members e.g TokenProvider, ... this is my ApplicationUserManager class: public class ApplicationUserManager : UserManager<User, long> { public ApplicationUserManager(IUserStore<User, long> store) : base(store) { } public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context) { var manager = new ApplicationUserManager(new CustomUserStore(context.Get

ASP.Net MVC 5 w/identity 2.2.0 Log off not working

天涯浪子 提交于 2019-11-30 12:26:25
问题 I am using a the basic login on a test ASP.Net MVC 5 site (for an internet site). The login works fine but when I try to logout it doesn't happen. The logout link does call the following controller action: public ActionResult LogOff() { AuthenticationManager.SignOut(); return RedirectToAction("Index", "Home"); } But the user stays logged in. How do I ensure that the user actually gets logged out? 回答1: I had this problem before, change: AuthenticationManager.SignOut(); To:

MVC Identity 2 using FormsAuthenticationTicket

﹥>﹥吖頭↗ 提交于 2019-11-30 09:32:40
问题 I am replacing the (HttpContext.Current.User) IPrincipal with a custom version so I can store more information login and the user. I have done this before using the FormsAuthtenticationTicket, but those other ways were based on the Memberhipship and SimpleMembership providers. My question is, can i use the FormsAuthenticationTicket to store the cookie of my ICustomPrincipal with it interfering or breaking in OWIN Identity Pipline? I feel like would i be mixing apples and oranges. example save

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

非 Y 不嫁゛ 提交于 2019-11-30 08:44:42
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, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result

ASP Identity 2.0: Regenerate Identity

偶尔善良 提交于 2019-11-30 05:33:36
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>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentityCallback: ((manager, user) => manager

Verify Access Token - Asp.Net Identity

余生长醉 提交于 2019-11-30 03:32:13
问题 I'm using ASP.Net Identity to implement external logins. After user logins in with Google I get google's external access token. I then make a second api call to ObtainLocalAccessToken() which trades the external access token for a new local one. ObtainLocalAccessToken() calls VerifyExternalAccessToken() which verifies the external access token with the provider by manually making http calls and parsing the user_id. How can I leverage ASP.NET identity to remove the entire method

How to add claims during user registration

懵懂的女人 提交于 2019-11-30 02:47:19
问题 I'm using ASP.NET MVC 5 project with identity 2.1.0 and VS2013 U4. I want to add claims to user during registration in order to be stored in db. These claims represent user custom properties. As I created a web page for administrator to create/edit/delete users, I'm still using create method from AccountController to create a user, but I don't want to login that user. How can I add those claims to the user ? 回答1: You probably already have a UserManager class. You can use that one to create

How can I get a users role inside a WebAPI method without a lookup to the AspNetUserRoles table?

不想你离开。 提交于 2019-11-29 20:19:49
I have a stored procedure that updates status. Depending on the role of the user the stored procedure has code that may or may not allow the status change. For this reason I need to pass a role name into a stored procedure. My role name is stored on the client in my javascript code but of course I need a second check on the server. Each user has only one of three roles and when requesting an update of status I can call one of three methods depending on the role that the client has. Here's what I tried. I am using WebApi with bearer Token based authentication and ASP.NET Identity 2.1 and the

MVC Identity 2 using FormsAuthenticationTicket

人盡茶涼 提交于 2019-11-29 15:56:30
I am replacing the (HttpContext.Current.User) IPrincipal with a custom version so I can store more information login and the user. I have done this before using the FormsAuthtenticationTicket, but those other ways were based on the Memberhipship and SimpleMembership providers. My question is, can i use the FormsAuthenticationTicket to store the cookie of my ICustomPrincipal with it interfering or breaking in OWIN Identity Pipline? I feel like would i be mixing apples and oranges. example save: var user = userRepository.Users.Where(u => u.Email == viewModel.Email).First();

Add relationships to the ApplicationUser class in ASP.NET Identity (Database First)

非 Y 不嫁゛ 提交于 2019-11-29 15:27:40
I'm using ASP.NET Identity (Database First) in my ASP.NET MVC application. I followed the instructions here , to set up the ASP.NET Identity with database first approach. My AspNetUsers table has a relationship with the Employee table (The Employee table has a UserId foreign key, and the AspNetUsers entity has an ICollection<Employee> property). I would like to add the ICollection<Employee> property to the ApplicationUser, like below: public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim> { public ICollection<Employee> Employees { get; set; } public