Skip to content
Snippets Groups Projects
Commit fc0d0f28 authored by Singh, Siddhartha (PG/T - Comp Sci & Elec Eng)'s avatar Singh, Siddhartha (PG/T - Comp Sci & Elec Eng)
Browse files

Merge branch 'fix/reset-email-url' into 'development'

Fix/reset email url

See merge request !73
parents cfa4910e 043a4ffa
Branches development
No related tags found
Loading
Pipeline #109090 passed
......@@ -187,6 +187,7 @@ def request_password_reset():
return jsonify({"error": "Email is required"}), 400
email = data['email'].strip().lower()
url = data['url']
try:
valid = validate_email(email)
email = valid.normalized
......@@ -213,7 +214,11 @@ def request_password_reset():
)
conn.commit()
reset_url = f"http://localhost:8000/reset_password/{token}"
reset_url = f"{url}/reset_password/{token}"
if reset_url.startswith("https://"):
reset_url = reset_url.replace("https://", "http://", 1)
subject = "Password Reset Request"
body = f"Click the following link to reset your password: {reset_url}\n\nThis link will expire in 1 hour.\n\nIf you did not request this, please ignore this email."
......
......@@ -102,12 +102,13 @@ if (loginForm) {
const email = document.getElementById('email').value;
const messageDiv = document.getElementById('message');
messageDiv.textContent = '';
const url = window.location.hostname
try {
const response = await fetch('/forgot_password', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email })
body: JSON.stringify({url, email })
});
const data = await response.json();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment