So I'm making a dapp. This portion uses smart contract for login. I need to add the ability to reset the user's password if they forget it.

contract Auth {
struct Credentials {
    string fullName;
    string email;
    string password;

mapping(string => Credentials) credential;

function createAccount(
    string memory name,
    string memory pass,
    string memory mail
) public {
    credential[mail].fullName = name;
    credential[mail].email = mail;
    credential[mail].password = pass;

function loginAccount(string memory mail, string memory pass)
    returns (string memory)
    if (
        keccak256(abi.encodePacked(credential[mail].password)) ==
    ) {
    } else {
        return "Wrong Password";

function resetAccount(string memory mail) public {
    //reset acc

Sorry I have no idea where to go with this.

  • 2
    Hey Julia, welcome to StackExchange! You might have misunderstood how blockhains works. Smart contracts are not databases. You should never store any private information, more especially user passwords, in an Ethereum smart contract. – Paul Razvan Berg May 6 at 18:27
  • In other words, anything you put a on a blockchain is public. In your case, anyone can see all the passwords for all the users. – Undead8 May 6 at 19:31
  • @PaulRazvanBerg interesting. I'm trying to figure out how I should handle the situation, as I'm making a travel ID Dapp – Julia Pak May 6 at 21:46
  • Hi Julia with a Dapp you probably don't even need a password. For example app.ens.domains only has a "Connect". docs.metamask.io/guide/… Paul and others may know good tutorials for this. – eth May 7 at 1:13

Your Answer

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

Browse other questions tagged or ask your own question.