DocSas/PropertyService.Domain/ModelView/Users/UserProvider.cs
/// <summary>
/// save new password as an asynchronous operation.
/// </summary>
/// <param name="userVM">The user vm.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
save new password as an asynchronous operation.
save new password as an asynchronous operation .
public async Task<DSCResponse> SaveNewPasswordAsync(UserVM userVM)
        {
            var msg = new Dictionary<string, string>();
            var response = new DSCResponse();
            var vericode = await _appCommon.GetVerificationCodeAsync(userVM.VericationCodeId);
            if (vericode == null)
            {
                msg.Add("SomethingWrong", "Something went wrong");
            }
            else
            {
                var entity = await _appCommon.GetUserAsync(vericode.UserId);
                var userVerify = _appCommon.IsUserAccountValid(entity);
                if (userVerify.IsSuccess)
                {
                    entity.UserSalt = SecurityManager.GenerateSalt();
                    entity.Password = SecurityManager.HashPassword(userVM.Password, entity.UserSalt);
                    var success = await _userRepo.ModifyAsync(entity);
                    if (!success)
                    {
                        msg.Add("SomethingWrong", "Something went wrong");
                    }
                }
                else
                {
                    msg = userVerify.ErrorMessage;
                }
            }
            response.ErrorMessage = msg;
            return response;
        }
public async Task < DSCResponse > SaveNewPasswordAsync ( UserVM userVM ) { var msg = new Dictionary < string , string > ( ) ; var response = new DSCResponse ( ) ; var vericode = await _appCommon . GetVerificationCodeAsync ( userVM . VericationCodeId ) ; if ( vericode == null ) { msg . Add ( " " , " " ) ; } else { var entity = await _appCommon . GetUserAsync ( vericode . UserId ) ; var userVerify = _appCommon . IsUserAccountValid ( entity ) ; if ( userVerify . IsSuccess ) { entity . UserSalt = SecurityManager . GenerateSalt ( ) ; entity . Password = SecurityManager . HashPassword ( userVM . Password , entity . UserSalt ) ; var success = await _userRepo . ModifyAsync ( entity ) ; if ( ! success ) { msg . Add ( " " , " " ) ; } } else { msg = userVerify . ErrorMessage ; } } response . ErrorMessage = msg ; return response ; }
save new password as an asynchronous operation.
save new password as an asynchronous operation .
//generate password salt //hash password
None
userVM
UserVM
The user vm.
The user vm .