This project is read-only.

Complex User lookup

Jun 4, 2014 at 4:05 PM
Edited Jun 4, 2014 at 4:09 PM
If you want to add a delete flag to the User table, where would you add it to the queries?

It appears that the supported way right now is to override and re-implement any methods in UserStore that return a User type. As of right now, that is only FindByNameAsync.

Can you provide a way to change the queries without re-implementing the Microsoft-provided logic? Not only do I have to re-implement FindByNameAsync, but also ThrowIfDisposed and GetUserAggregateAsync (since they are private methods).
Jun 10, 2014 at 7:01 PM
The GetUserAggregateAsync is made protected in 2.1.0. So you can work with that
Jun 26, 2014 at 4:42 PM
I am working on a solution based on the Microsoft.AspNet.Identity.Samples V2.1.0-alpha1) and need the same thing.

I have custom Identity classes as I need to have a User PK of type Int.

So, in MyCustomUserManager I set user.Active:
    public override async Task<IdentityResult> DeleteAsync(CodeProjectUser user)
        // return base.DeleteAsync(user);
        user.Active = false;
        var result = await base.UpdateAsync(user);
        if (result != IdentityResult.Success)
            return result;

        return await UpdateSecurityStampAsync(user.Id);
and in MyCustomSignInManager I check user.Active. I'm also looking up user by email as I don't store the email in both UserName and Email but want to sign in by Email.:
    // Uses the users email as the user identifier instead of the userName.
    public override async Task<SignInStatus> PasswordSignInAsync(string email, string password, bool isPersistent, bool shouldLockout)
        var user = await UserManager.FindByEmailAsync(email);
        if (user == null || !user.Active)
            return SignInStatus.Failure;

        return await base.PasswordSignInAsync(user.UserName, password, isPersistent, shouldLockout);