-
Notifications
You must be signed in to change notification settings - Fork 147
Made password reset flow functional and also added username selection(with uniqueness check) on the signup form #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chandansgowda
merged 4 commits into
AOSSIE-Org:main
from
Saahi30:feature/supabase-password-reset-flow
Jun 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e3d9346
feat: improved Supabase password reset flow, username check, and UX eβ¦
Saahi30 3f8b63d
chore: add explainer comments to password reset, signup, and auth flows
Saahi30 795ae23
feat: username validation, canonical email, and frontend improvementsβ¦
Saahi30 34e7fa0
chore: update after review or manual change
Saahi30 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,41 @@ | ||
| import { useState } from "react"; | ||
| import { Link } from "react-router-dom"; | ||
| import { ArrowLeft, Check, Rocket } from "lucide-react"; | ||
| import { supabase } from "../utils/supabase"; | ||
|
|
||
| export default function ForgotPasswordPage() { | ||
| const [email, setEmail] = useState(""); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [isSubmitted, setIsSubmitted] = useState(false); | ||
| const [error, setError] = useState(""); | ||
| const [showSignupPrompt, setShowSignupPrompt] = useState(false); | ||
|
|
||
| const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
| setIsLoading(true); | ||
| setError(""); | ||
| setShowSignupPrompt(false); | ||
|
|
||
| try { | ||
| // In a real app, you would call your auth API here | ||
| await new Promise((resolve) => setTimeout(resolve, 1500)); | ||
| // Check if email exists in users table | ||
| const { data: users, error: userError } = await supabase | ||
| .from("users") | ||
| .select("id") | ||
| .eq("email", email) | ||
| .maybeSingle(); | ||
| if (userError) throw userError; | ||
| if (!users) { | ||
| setShowSignupPrompt(true); | ||
| setIsLoading(false); | ||
| return; | ||
| } | ||
| const { error } = await supabase.auth.resetPasswordForEmail(email, { | ||
| redirectTo: window.location.origin + "/reset-password" | ||
| }); | ||
| if (error) throw error; | ||
| setIsSubmitted(true); | ||
| } catch (err) { | ||
| setError("Something went wrong. Please try again."); | ||
| } catch (err: any) { | ||
| setError(err.message || "Something went wrong. Please try again."); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
|
|
@@ -88,6 +105,12 @@ export default function ForgotPasswordPage() { | |
| </div> | ||
| )} | ||
|
|
||
| {showSignupPrompt && ( | ||
| <div className="mb-6 p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg text-yellow-700 dark:text-yellow-400 text-sm animate-[pulse_1s_ease-in-out]"> | ||
| No account found with this email. <Link to="/signup" className="underline text-purple-600">Sign up?</Link> | ||
| </div> | ||
| )} | ||
|
|
||
| <form onSubmit={handleSubmit} className="space-y-6"> | ||
| <div className="space-y-2"> | ||
| <label | ||
|
|
@@ -103,7 +126,7 @@ export default function ForgotPasswordPage() { | |
| onChange={(e) => setEmail(e.target.value)} | ||
| required | ||
| className="w-full px-4 py-3 rounded-lg border border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-purple-500 dark:focus:ring-purple-400 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-all duration-200" | ||
| placeholder="[email protected]" | ||
| placeholder="[email protected] (CASE sensitive)" | ||
| /> | ||
| </div> | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the email lookup in the
userstable and the subsequent call toresetPasswordForEmail:userstable stores emails as they are entered, or if you want to ensure case-insensitive lookup matching Supabase's behavior, it's advisable to convert the input email to lowercase before querying and before passing toresetPasswordForEmail. This would be.eq("email", email.toLowerCase())andsupabase.auth.resetPasswordForEmail(email.toLowerCase(), ...).[email protected] (CASE sensitive)(line 129) could be confusing if Supabase Auth itself handles emails case-insensitively. Aligning the logic (e.g., by usingtoLowerCase()) would make the UX more consistent.Could you clarify if emails are stored/handled case-sensitively throughout, or if normalizing to lowercase here would be more appropriate?