# Magento Admin Reset Password: Common Bugs and Fixes

Password recovery for the Magento admin panel often encounters several issues caused by a few bugs. Here's a concise overview and their solutions:

**Password reset link includes an extra path**  
The URL contains an unnecessary `/admin` segment after the main domain, e.g.:  
`http://magento.local/admin/admin_123456/admin/auth/resetpassword/key/xxxxxxxxxx/?id=1&token=yyyyyyyy`  
Solution: Apply the patch suggested in [this comment](https://github.com/magento/magento2/issues/35667#issuecomment-1943505361).  
Note: This issue exists in Magento 2.4.6 but has been fixed in version 2.4.7.

**Missing password reset form**  
This issue is documented [here](https://github.com/magento/magento2/issues/13349). After upgrading Magento, the form might disappear, even with all custom modules disabled. A patch is needed to resolve this

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729319949852/71584df4-b70e-4dec-95b1-3392a7906122.png align="center")

```php
diff --git a/view/adminhtml/layout/adminhtml_auth_resetpassword.xml b/view/adminhtml/layout/adminhtml_auth_resetpassword.xml
index 3ee2rd..8349152 111644
--- a/view/adminhtml/layout/adminhtml_auth_resetpassword.xml    2024-10-16 23:10:32.714755233 +0200
+++ b/view/adminhtml/layout/adminhtml_auth_resetpassword.xml	2024-10-16 23:11:13.808563121 +0200

@@ -9,7 +9,7 @@
     <update handle="admin_login" />
     <body>
         <referenceContainer name="login.content">
-            <block class="Magento\Backend\Block\Template" name="content" template="Magento_User::admin/resetforgottenpassword.phtml" />
+            <block class="Magento\Backend\Block\Template" name="content.reset.password" template="Magento_User::admin/resetforgottenpassword.phtml" />
         </referenceContainer>
     </body>
 </page>
```

Add this into composer.json:

```php
"extra": {
    "magento-force": "override",
    "composer-exit-on-patch-failure": true,
    "patches": {
        "magento/module-user": {
             "Reset password form for admin": "patches/composer/admin_password_reset_form.patch",
        }
    }
},
```

**Expired password reset link**  
Modifying the form block leads to the error: "Your password reset link has expired." This occurs because the token is not added to the form.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729319413533/ea08d964-7d6f-4940-99de-e9b31e0fcc86.png align="center")

Another patch is required to fix this issue.

```php

--- /dev/null
+++ ../Controller/Adminhtml/Auth/ResetPassword.php
@@ -24,7 +24,7 @@

             $this->_view->loadLayout();

-            $content = $this->_view->getLayout()->getBlock('content');
+            $content = $this->_view->getLayout()->getBlock('content.reset.password');
             if ($content) {
                 $content->setData('user_id', $userId)->setData('reset_password_link_token', $passwordResetToken);
```

```php
"extra": {
    "magento-force": "override",
    "composer-exit-on-patch-failure": true,
    "patches": {
        "magento/module-user": {
            "fix admin post reset": "patches/composer/magento-module-user-controller-adminhtml-auth-resetpassword-php.patch"
        }
    }
},
```

**Missing 'id' parameter**  
Sometimes the password reset link leads to an "expired link" message due to a missing `id` parameter in the file:  
`vendor/magento/module-user/view/adminhtml/templates/admin/resetforgottenpassword.phtml`:

```php
<form method="post" data-mage-init='{"form": {}, "validation": {}}'
      action="<?= $block->escapeUrl(
          $block->getUrl(
              '*/auth/resetpasswordpost',
              ['_query' => ['id' => $block->getUserId(), 'token' => $block->getResetPasswordLinkToken()]]
          )
      ) ?>" id="reset-password-form" autocomplete="off">
```

These issues require applying several patches to ensure the password recovery function works correctly in the Magento admin panel.
