Skip to content

feat: allow reset password#166

Merged
schwannden merged 1 commit intomainfrom
feat/reset-password
Aug 10, 2025
Merged

feat: allow reset password#166
schwannden merged 1 commit intomainfrom
feat/reset-password

Conversation

@schwannden
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings August 7, 2025 10:08
@schwannden schwannden force-pushed the feat/reset-password branch from 6bc17a9 to 46e9f7f Compare August 7, 2025 10:08
@schwannden schwannden changed the title feat/reset-password feat: allow reset password Aug 7, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements comprehensive password reset functionality across authentication and profile management areas. It enables users to handle password operations through both email-based reset flows and profile-based password management, with different interfaces for Google OAuth versus email/password users.

Key changes include:

  • Added password change/setup forms in the profile section with user type detection
  • Implemented password reset confirmation handling in the auth callback flow
  • Created reusable auth service for password operations
  • Enhanced existing password reset email functionality with improved UX

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pages/AuthCallbackPage.tsx Added password recovery event detection and reset form rendering
src/lib/auth-service.ts Created service for password operations including update and verification
src/components/Profile/ProfileForm.tsx Added security section with conditional password forms based on user type
src/components/Profile/PasswordSetupForm.tsx New form for Google OAuth users to set up passwords
src/components/Profile/PasswordChangeForm.tsx New form for email users to change existing passwords
src/components/Auth/SignInForm.tsx Enhanced password reset UX with better error handling
src/components/Auth/ResetPasswordForm.tsx New form for handling password reset confirmation
public/locales/*/profile.json Added security-related translation keys
public/locales/*/auth.json Added password validation and reset-related translations
PRPs/reset-password-implementation.md Implementation documentation and requirements

Comment on lines +25 to +37
export async function verifyCurrentPassword(email: string, currentPassword: string): Promise<void> {
const { error } = await supabase.auth.signInWithPassword({
email: email,
password: currentPassword,
});

if (error) {
console.error("Error verifying current password:", error);
if (error.message?.toLowerCase().includes("invalid login credentials")) {
throw new Error("Current password is incorrect");
}
throw new Error(`Failed to verify current password: ${error.message}`);
}
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The verifyCurrentPassword function attempts a sign-in to verify the password, which could create a new session. This approach may interfere with the user's current session and could be exploited for session hijacking. Consider using a dedicated password verification endpoint or implementing a different verification strategy that doesn't create a new session.

Suggested change
export async function verifyCurrentPassword(email: string, currentPassword: string): Promise<void> {
const { error } = await supabase.auth.signInWithPassword({
email: email,
password: currentPassword,
});
if (error) {
console.error("Error verifying current password:", error);
if (error.message?.toLowerCase().includes("invalid login credentials")) {
throw new Error("Current password is incorrect");
}
throw new Error(`Failed to verify current password: ${error.message}`);
}
/**
* This function is unsafe because it attempts to verify the password by signing in,
* which can create a new session and interfere with the user's current session.
* Do not use this function. Instead, implement password verification on a secure backend endpoint.
*/
export async function verifyCurrentPassword(email: string, currentPassword: string): Promise<void> {
throw new Error(
"verifyCurrentPassword is unsafe and has been disabled. " +
"Implement password verification on a secure backend endpoint that does not create a new session."
);

Copilot uses AI. Check for mistakes.
data: { subscription },
} = supabase.auth.onAuthStateChange((event, _session) => {
if (event === "PASSWORD_RECOVERY") {
console.log("Password recovery event detected");
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from production code. Consider using a proper logging service or removing this debug statement.

Suggested change
console.log("Password recovery event detected");

Copilot uses AI. Check for mistakes.
setIsSubmitting(true);
try {
// First verify the current password
await verifyCurrentPassword(user.email, values.currentPassword);
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

Using verifyCurrentPassword could create a new session while the user is already authenticated. This may cause session conflicts or security issues. Consider alternative verification methods that don't involve creating new authentication sessions.

Suggested change
await verifyCurrentPassword(user.email, values.currentPassword);
await checkPassword(user.email, values.currentPassword);

Copilot uses AI. Check for mistakes.
@schwannden schwannden merged commit 643820a into main Aug 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants