How do I change the current optional password in edit account section in Magento 2 as customer is already logged in, hence I don't want customer to put the current password again for the store. How can I achieve this for my store?


You can achieve this my following steps:

Step 1: Copy the below file to your theme:


And remove required class from below section:

<div class="field password current">
    <label class="label" for="current-password"><span><?= $block->escapeHtml(__('Current Password')) ?></span></label>
    <div class="control">
        <input type="password" class="input-text" name="current_password" id="current-password" data-input="current-password" autocomplete="off" />

Step 2: Copy the below file to your theme:


and change the method _showAll:

_showAll: function () {


    //$(this.options.currentPasswordSelector).attr('data-validate', '{required:true}').prop('disabled', false); // Comment this line
    $(this.options.currentPasswordSelector).prop('disabled', false); // Added this line
    $(this.options.emailSelector).attr('data-validate', '{required:true}').prop('disabled', false);
        '{required:true, equalTo:"' + this.options.newPasswordSelector + '"}'
    ).prop('disabled', false);

Step 3: Override the following class


and change the function changePasswordForCustomer(Its private method if override not working then try to edit the vendor class)

private function changePasswordForCustomer($customer, $currentPassword, $newPassword)
    try {
        //$this->getAuthentication()->authenticate($customer->getId(), $currentPassword); // Comment this line
    } catch (InvalidEmailOrPasswordException $e) {
        throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
    $customerEmail = $customer->getEmail();
    $this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $newPassword);
    $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());

    return true;

Vendor edit is not good practice.

| improve this answer | |
  • How to handle current password in AccountManagement model file...... – Mahi M Jul 13 '18 at 18:35
  • Did you try to change the function I have mentioned? This function ignores the current password validation and checking. – Sukumar Gorai Jul 13 '18 at 18:38
  • Yes. i have done it. But i need to override account management in my module file ....How to solve this...I spend lot of time for this.. – Mahi M Jul 13 '18 at 18:40
  • Without override everything works fine as you want? – Sukumar Gorai Jul 13 '18 at 18:42
  • Yes.....its working fine – Mahi M Jul 13 '18 at 18:43

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.