get current user password on the profile edit page

This cannot be done, it is not possible, and it would be an awful thing to do if it was. Do not attempt or pursue this.

Why It Is Not Possible

Passwords are ran through a 1 way hashing function before being stored in the database. This allows us to check if a password matches but we can’t undo the hash. To do that, we would need to brute force the password which could take decades or even centuries depending on its length.

This is so that if the password hash is revealed, it’s not possible to then plug it into other sites. Passwords are salted with secret keys before hashing so that
those hashes are unique to your site.

Legality

You might then think we can store the passwords in plaintext, or use a magical unhashing function. In many countries this would be illegal, and grounds for lawsuits.

For example, in the EU and UK, this would breach numerous data protection and privacy regulations, as well as other laws aimed at preventing negligence.

You would also fail the various forms of PCI compliance, and any security audits. This would mean any kind of sales on your site would breach consumer laws and regulations across multiple continents.

On top of that, any of your users who found out could sue for negligent mishandling of personal data.

Security

This would allow any admin to steal user credentials. Coupled with the fact that users tend to reuse passwords, anybody with elevated access to the site could compromise the emails and other accounts of those users, leading to:

  • regulatory action
  • bad reputation
  • data loss
  • lawsuits

The TLDR:

  • passwords are stored as hashes, you can’t un-hash the password
  • even if you could, it’s a dangerous thing to do financially, legally, and heavily compromises your sites security
  • If you have users who have forgotten their password, use a reset password email with a link.
  • If you want to make logging in easier for your users, and to make account recovery easy, this is not the way to do it. There are industry accepted norms such as Signing in using FB/Google, logging in with a link in an email, password managers, etc, that are all easier and more secure