Skip to content

feat: implemented password reset#24

Merged
koldakov merged 1 commit into
koldakov:mainfrom
omthorat2004:feat/password-reset
May 2, 2026
Merged

feat: implemented password reset#24
koldakov merged 1 commit into
koldakov:mainfrom
omthorat2004:feat/password-reset

Conversation

@omthorat2004
Copy link
Copy Markdown
Contributor

Closes #23

Summary

Add password reset functionality allowing users to request a reset link via email and securely update their password through a token-based flow.

Changes

  • Add forgot password modal in templates/auth.html with email input
  • Add client-side rate limiting using localStorage to prevent repeated requests (cooldown timer)
  • Add POST /api/users/passwords/request-change to trigger password reset flow
  • Implement secure token generation and validation for password reset links
  • Add password reset form (templates/password_change.html)
  • Add GET route to validate token and render password change form
  • Add POST route to update password after validation
  • Handle invalid/expired tokens with user-friendly error messages
  • Add success and error states with proper UI feedback
  • Add redirect with messageType=password_changed after successful reset

Validation

  • Verified reset link request flow with cooldown timer
  • Tested token validation for valid, invalid, and expired cases
  • Ensured password update works correctly and invalidates old tokens
  • Confirmed proper UI feedback and redirects

Notes

  • Client-side rate limiting complements backend validation (not a security boundary)
  • Token-based flow designed to be stateless and secure
  • UX optimized with modal-based interaction and real-time feedback

@omthorat2004 omthorat2004 force-pushed the feat/password-reset branch 6 times, most recently from 93f11a1 to a878a55 Compare April 28, 2026 16:26
Comment thread futuramaapi/core/_settings.py Outdated
class Settings(BaseSettings):
allow_origins: list[str]
backend_url: HttpUrl
scheme: str = "http"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly use https by default

Comment thread templates/auth.html Outdated
Comment on lines +136 to +164
<script>
const BACKEND_URL = "{{ backend_url }}";

let timerInterval = null;

function openForgotPasswordModal(event) {
event.preventDefault();

const modal = document.getElementById('forgotPasswordModal');
const messageDiv = document.getElementById('forgotPasswordMessage');
const submitButton = document.querySelector('#forgotPasswordForm button[type="submit"]');

modal.classList.add('show');
document.getElementById('reset-email').focus();

// Reset message
messageDiv.classList.add('hidden');
messageDiv.textContent = '';

const { allowed, timeRemaining } = canRequestPasswordReset();

if (!allowed) {
messageDiv.classList.remove('hidden');
messageDiv.className = 'auth-message error';
startCountdown(messageDiv, timeRemaining, submitButton);
} else {
submitButton.disabled = false;
}
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS code looks good, however please move the code to the corresponding .js file

Comment thread .env.test Outdated
@@ -1,7 +1,9 @@
ALLOW_ORIGINS=*
BACKEND_URL=http://localhost:8080
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don’t need multiple sources of truth for the same thing. Since BACKEND_URL already includes both the scheme and the host, TRUSTED_HOST and SCHEME are redundant and can be derived from it. Keeping them separately increases the risk of inconsistencies over time.

It’s better to rely on a single env var BACKEND_URL and compute the rest from it.

With Pydantic, you can use computed_field to calculate these values cleanly from the URL.

@omthorat2004 omthorat2004 force-pushed the feat/password-reset branch 2 times, most recently from 3811ba3 to 17d8196 Compare April 30, 2026 17:24
@omthorat2004 omthorat2004 force-pushed the feat/password-reset branch from 30be589 to a84311d Compare May 2, 2026 16:23
@koldakov koldakov merged commit fb88549 into koldakov:main May 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reset password Page

2 participants