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

后端 未结 2 538
谎友^
谎友^ 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

提交回复
热议问题