How to give custom implementation of UpdateAsync method of asp.net identity?

后端 未结 2 530
谎友^
谎友^ 2020-12-02 01:21

I am doing custom asp.net identity and not using asp.net inbuilt tables.I have successfully created user with implementing custom CreateAsync

Now i want

相关标签:
2条回答
  • 2020-12-02 01:31

    Not sure if this is what your looking for...

    public Task UpdateAsync(UserModel model)
    {
        var user = _dbContext.User.Find(x => x.id == model.id);
        user.Password = model.Password;
        _dbContext.SaveChanges();
        return Task.CompletedTask;
    }
    

    It Will get the specific record and Update the password and then save the record.

    Edit

    Since the password is not getting encrypted i added code to take that string and leave the model as it is, this extension method will encrypt the value of password, i have not test this but i am sure it will work.

     user.Password = model.Password.EncryptPassword(EncryptKey);
    

    Extension methods to encrypt password

    0 讨论(0)
  • 2020-12-02 01:43

    Sometime back, I created a complete wrapper over .NET Identity and code can be found here. It might be helpful for you. You can also find nuget here. I also explained the library in a blog here.

    0 讨论(0)
提交回复
热议问题