Skip to content

Add forgot password option #55

@JiyaBatra

Description

@JiyaBatra

🚨 Feature Request: Add Forgot Password Option

Description:
Currently, the project does not have a "Forgot Password" option, which makes it difficult for users to recover their accounts if they forget their credentials.

Expected Behavior:
A "Forgot Password" feature should be added to the login page. When clicked, it should allow users to reset their password (e.g., via email or a simple reset flow).

Tech Stack:
The project is built using HTML, CSS, and JavaScript, so the implementation should be done using these technologies.

Why This is Needed:
Adding this feature will improve user experience and make the authentication system more complete and user-friendly.

### 💡 Approach (Frontend-only demo logic)

We’ll simulate:

User clicks Forgot Password
Enters email
Gets a “reset link” (fake / simulated)
Sets new password
Password updates in local storage
🧱 Step 1: Store users (LocalStorage)

When user registers:

localStorage.setItem("user", JSON.stringify({
  email: "test@gmail.com",
  password: "1234"
}));

🔐 Step 2: Forgot Password UI
<a href="forgot.html">Forgot Password?</a>
📩 Step 3: Email input (forgot.html)

<input type="email" id="email" placeholder="Enter your email" />
<button onclick="checkEmail()">Reset Password</button>
<p id="msg"></p>

⚙️ Step 4: Check email exists

function checkEmail() {
  const email = document.getElementById("email").value;
  const user = JSON.parse(localStorage.getItem("user"));

  if (user && user.email === email) {
    localStorage.setItem("resetUser", email);
    window.location.href = "reset.html";
  } else {
    document.getElementById("msg").innerText = "Email not found!";
  }
}

🔁 Step 5: Reset password page (reset.html)

<input type="password" id="newPass" placeholder="New Password" />
<button onclick="resetPassword()">Update Password</button>
<p id="msg"></p>
🔄 Step 6: Update password logic
function resetPassword() {
  const newPass = document.getElementById("newPass").value;
  const email = localStorage.getItem("resetUser");
  let user = JSON.parse(localStorage.getItem("user"));

  if (user && user.email === email) {
    user.password = newPass;
    localStorage.setItem("user", JSON.stringify(user));
    localStorage.removeItem("resetUser");

    document.getElementById("msg").innerText = "Password updated!";
  }
}

```⚠️ Important Reality Check

This is:

✅ Good for learning
✅ Good for mini projects
❌ NOT secure (no encryption, no real email verification)

Metadata

Metadata

Assignees

Labels

jwocThis project is under jwoc

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions