Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle ASP.NET Identity records in node.js?

I want to move from ASP.NET MVC Identity to node.js. I have the following field in my database:

PasswordHash: AOCB5TrZGusq9ZUdYd/w/u7GUZTPOMG7JhFd4JgS0gLOulL8QjZRbl4T6sPXwD3lfQ==

The password is asdfgak. I have no idea how to use this PasswordHash and how to get the hash and salt from it to login users from node.js.

I saw this answer but it didn't help at all, the output from this was the following:

A+w9Dyfupc+dMkViA0eYF4ol7HhdIfVPct6o47a+n5M=

Here is the code that I have in my MVC project, if that helps:

public class ApplicationUser : IdentityUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }

    // my custom fields like username, gender...
}

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("Personal", throwIfV1Schema: false)
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}
like image 981
Luca Steeb Avatar asked Sep 03 '25 05:09

Luca Steeb


1 Answers

Ok, I found this module where you can even choose between sync & async, it's awesome:

https://www.npmjs.com/package/aspnet-identity-pw

like image 91
Luca Steeb Avatar answered Sep 04 '25 20:09

Luca Steeb