Tuesday, December 24, 2013

Just Asp.net Identity Core

Before You dive further please go through these blogpost for more clarity and brevity.

  1. No Entity Framework.
  2. No Asp.net database tables
  3. Use existing Database user table for authentication.
Have extended and used following Interface and class
1. IUser
2. IUserStore
3. UserManager

In order to refer our own table we have extended the method FindSync of UserManager.

public class CustomUserManager:UserManager<ApplicationUser>


public CustomUserManager() : base(new CustomUserSore<ApplicationUser>())


//We can retrieve Old System Hash Password and can encypt or decrypt old password using custom approach.

this.PasswordHasher = new OldSystemPasswordHasher();


public override System.Threading.Tasks.Task<ApplicationUser> FindAsync(string userName, string password)


Task<ApplicationUser> taskInvoke = Task<ApplicationUser>.Factory.StartNew(() =>


//First Verify Password...

PasswordVerificationResult result = this.PasswordHasher.VerifyHashedPassword(userName, password);

if (result == PasswordVerificationResult.SuccessRehashNeeded)


//Return User Profile Object...

//So this data object will come from DB via Nhiberanate

ApplicationUser applicationUser = new ApplicationUser();

applicationUser.UserName =

return applicationUser;


return null;


return taskInvoke;



For Source code

Post a Comment