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

放肆的年华 提交于 2019-11-27 09:37:32
Sarel Louw

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

        public Task UpdateAsync(UserModel model)
    {
        return Task.Factory.StartNew(() =>
        {
           var user = _dbContext.User.Find(x => x.id == model.id);

            user.Password = model.Password;
            _dbContext.SaveChanges();
        });
    }

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!