Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions Frontend/src/pages/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,36 @@ export default function SignupPage() {
try {
const { name, email, password } = formData;

// Check if user already exists
const { data: existingUser } = await supabase.auth.signInWithPassword({
email,
password: "dummy-password-to-check-existence",
});

if (existingUser.user) {
setError("An account with this email already exists. Please sign in instead.");
setIsLoading(false);
return;
}

// Attempt to sign up the user directly
const { data, error } = await supabase.auth.signUp({
email,
password,
options: { data: { name } },
});

if (error) {
if (error.message.includes("already registered")) {
// Handle specific error cases
if (error.message.includes("already registered") ||
error.message.includes("already exists") ||
error.message.includes("already been registered")) {
setError("An account with this email already exists. Please sign in instead.");
} else {
setError(error.message);
}
setIsLoading(false);
return;
}

// Check if signup was successful
if (data.user) {
// User was created successfully
console.log("User signed up successfully:", data.user);
// AuthContext will handle navigation based on user onboarding status and role
}
Comment on lines +66 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove or sanitize console logging to prevent information disclosure.

The console.log statement may expose sensitive user information including email, user ID, and other metadata that could be useful for attackers.

Apply this diff to remove sensitive information logging:

-        console.log("User signed up successfully:", data.user);
+        console.log("User signed up successfully");

Or if logging is needed for debugging, sanitize the output:

-        console.log("User signed up successfully:", data.user);
+        console.log("User signed up successfully:", { id: data.user.id, email: data.user.email });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (data.user) {
// User was created successfully
console.log("User signed up successfully:", data.user);
// AuthContext will handle navigation based on user onboarding status and role
}
if (data.user) {
// User was created successfully
console.log("User signed up successfully");
// AuthContext will handle navigation based on user onboarding status and role
}
🤖 Prompt for AI Agents
In Frontend/src/pages/Signup.tsx around lines 66 to 70, the console.log
statement outputs sensitive user information which risks information disclosure.
Remove the console.log entirely or replace it with a sanitized log that excludes
sensitive fields like email and user ID, ensuring no private data is exposed in
the console.


setIsLoading(false);
// AuthContext will handle navigation based on user onboarding status and role
} catch (err) {
console.error("Signup error:", err);
setError("Something went wrong. Please try again.");
} finally {
setIsLoading(false);
Expand Down