-1

How can i programatically change customer password in magento 2? can anyone please help me to solve this

1

Magento\Customer\Model\ResourceModel\CustomerRepository has an extra argument passwordHash

Use this argument to set a new password:

$customer = $this->customerRepository->getById($customerId);
$this->customerRepository->save($customer, $this->encryptor->getHash($password, true));
  • @ i have used the above code but the password is not changing – srg Aug 17 '17 at 12:33
  • what issue generated? – Rohan Hapani Sep 1 '17 at 18:49
  • how to define encryptor because i am getting error – Rv Singh Sep 28 '18 at 13:52
  • @RohanHapani, will it work if we load customer object with customerFactory ? – jafar pinjar Dec 5 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.