asp.net-identity-2

Accessing logged in user Id from class - MVC 5, AutoMapper and Identity 2.0

心已入冬 提交于 2019-12-14 02:34:03
问题 So In my project have implemented interfaces and AutoMapper, and Identity 2.0 with Id as int modification form here: http://typecastexception.com/post/2014/07/13/ASPNET-Identity-20-Extending-Identity-Models-and-Using-Integer-Keys-Instead-of-Strings.aspx Question is how to access ApplicationUserManager properties from: public class EnteredByResolver : ValueResolver<ExcursionVM, int> { protected override int ResolveCore(ExcursionVM source) { return 1; // TODO - need to access loged user Id to

How to delete user in web api?

青春壹個敷衍的年華 提交于 2019-12-13 04:43:47
问题 I have created a web api with Individual User authentication. After user get registered his information is stored in 2 tables, his general information is stored in "AspNetUsers" table and his role is stored in "AspNetUserRoles" table. Now the problem is when I am trying to delete any user from the list, its not working.Here is the delete action: [ResponseType(typeof(AspNetUser))] [ActionName("EmployeeInfo")] [DeflateCompression] public IHttpActionResult DeleteEmployeeInformation(string Id) {

Reuse existing ASP.NET-MVC 5 Identity 2 authorization for WEB API OData controllers to make it easy to login for other apps?

梦想的初衷 提交于 2019-12-12 13:04:32
问题 I have complete ASP.NET-MVC5 application which I extended by the WEB API 2 OData controllers. For instance I have: public class PersonController : ODataController and MVC controller which demands authorization [Authorize] public class PersonController : Controller Both contollers use ApplicationDbContext where my DbSets are I don't want to give data about person to everyone in the world through WEB API controller. I already have User , Moderator and Admin roles in my MVC application. Can I

HttpContext.Current is null inside Identity Framework's methods

丶灬走出姿态 提交于 2019-12-12 09:37:01
问题 I am using ASP.NET MVC 5 and Identity Framework. When I call UserManager.UpdateAsync(...) my eventhandlers on ApplicationDbContext() SaveChanges will run. Here I am using HttpContext.Current for different purposes (logging and auditing) so I must get say current user. However the whole method runs in a worker thread, and here HttpContext.Current is null. The biggest problem that the UserManager's "sync" methods are only wrappers around the async version, so the calls are serialized, but the

ASP.NET Identity 2.0: How to rehash password

眉间皱痕 提交于 2019-12-12 08:47:40
问题 I am migrating users from a legacy user store to ASP.NET Identity 2.0 in my ASP.NET 5.0 web application. I have a means of verifying legacy hashes, but I want to upgrade them at login-time to ASP.NET Identity 2.0 hashes. I've created a custom IPasswordHasher that is able to detect and verify legacy hashes, and return PasswordVerificationResult.SuccessRehashNeeded at the appropriate time. (If it detects that the hash is not legacy, it simply falls through to the built-in ASP.NET Identity hash

ASPNET Identity Caching with Dependency Injection

纵然是瞬间 提交于 2019-12-12 06:22:21
问题 I am using Ninject in an MVC application with ASPNET Identity 2. Log in, log out, updating password etc are all working fine. However if I update the user's name in the database, the ApplicationUserManager seems to be caching the user information. This is the code to register the Identity services: private void RegisterServices() { kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); var dbContext = kernel.Get<ApplicationDbContext>(); kernel.Bind<IUserStore

Extend ASP .NET Identity with custom List<property> and access it in the View

天涯浪子 提交于 2019-12-12 04:57:46
问题 I am using ASP NET Identity 2.0. I need to extend the identity model with an ApplicationOrganization class (many-to-many with ApplicationUser). So I created new class, ApplicationOrganization with; public virtual ICollection<ApplicationUser> Users { get; set; } public virtual ICollection<ApplicationOrganization> Organizations { get; set;} to ApplicationUser class to create a many-to-many relationship. I would like to add some combo (html select tag) with available organizations into _Layout

ASP.NET Identity2 - How to get User Id with AllowAnonymous Controller?

青春壹個敷衍的年華 提交于 2019-12-12 00:32:32
问题 I would like to save in a database(date and user) who views a web page that can be accessed by a authorized and anonymous users. Is there a way to make an action to work with both types because if the action is [AllowAnonymous] , the user is not authenticated and I can't retrieve the user id and if the action is [Authorize] the anonymous users can't access the page. [HttpGet] [Route("{id}/Detail")] [AllowAnonymous] [ResponseType(typeof(JsonArticleDetail))] public IHttpActionResult GetArticle

The entity type ApplicationUser is not part of the model : Using Webforms

南笙酒味 提交于 2019-12-11 17:48:43
问题 I have reviewed several answers to this on StackOverflow, and I have applied and compared with no answer to my particular case. Here is what I have up to this point: *****In Web.Config***** <add name="DefaultConnection" connectionString="Data Source=LAPTOP-2UA8GL6L\SQLEXPRESS;Initial Catalog=FHSF_DEV;Integrated Security=True" providerName="System.Data.SqlClient" /> in IdentityModels.cs public class ApplicationUser : IdentityUser { public DateTime BirthDate { get; set; } public string City {

Injecting ISecureDataFormat in Web API 2 AccountController using Autofac

房东的猫 提交于 2019-12-11 16:28:45
问题 I am using ASP.NET Identity 2.2 in a Web API 2 project but I am unsure how to wire up the ISecureDataFormat<AuthenticationTicket> dependency of the AccountController using Autofac . I tried this: builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>() .As<TicketDataFo‌​rmat>(); and getting error: The type 'Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.Authenticat‌​ionTicket]' is not assignable to service 'Microsoft.Owin.Security.DataHandler.TicketDataFormat' None