-
-
Notifications
You must be signed in to change notification settings - Fork 175
feat(ui): implement password recovery flow #5863
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
Open
luizhf42
wants to merge
1
commit into
master
Choose a base branch
from
feat/ui-react/password-recovery-flow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+401
−7
Open
Changes from all commits
Commits
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 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
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 |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import { useState, FormEvent } from "react"; | ||
| import { Link } from "react-router-dom"; | ||
| import { | ||
| EnvelopeIcon, | ||
| CheckCircleIcon, | ||
| LockClosedIcon, | ||
| } from "@heroicons/react/24/outline"; | ||
| import { recoverPassword } from "../api/auth"; | ||
|
|
||
| export default function ForgotPassword() { | ||
| const [account, setAccount] = useState(""); | ||
| const [loading, setLoading] = useState(false); | ||
| const [sent, setSent] = useState(false); | ||
|
|
||
| const handleSubmit = async (e: FormEvent) => { | ||
| e.preventDefault(); | ||
| setLoading(true); | ||
| try { | ||
| await recoverPassword(account.trim()); | ||
| } catch { | ||
| // Silently ignore to prevent user enumeration. | ||
| } finally { | ||
| setLoading(false); | ||
| setSent(true); | ||
| } | ||
luizhf42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| return ( | ||
| <div className="w-full max-w-5xl mx-auto px-8 py-12 flex flex-col items-center"> | ||
| {/* Hero */} | ||
| <div className="text-center mb-12 animate-fade-in"> | ||
| <div className="animate-float mb-6 inline-block"> | ||
| <div className="w-20 h-20 rounded-2xl bg-primary/15 border border-primary/25 flex items-center justify-center shadow-lg shadow-primary/10"> | ||
| <LockClosedIcon className="w-10 h-10 text-primary" strokeWidth={1.2} /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <p className="text-2xs font-mono font-semibold uppercase tracking-wide text-primary/80 mb-2"> | ||
| Password Recovery | ||
| </p> | ||
| <h1 className="text-3xl font-bold text-text-primary mb-3"> | ||
| Forgot your password? | ||
| </h1> | ||
| <p className="text-sm text-text-muted max-w-md mx-auto leading-relaxed"> | ||
| Enter your username or email address and we'll send you a link to | ||
| reset your password. | ||
| </p> | ||
| </div> | ||
|
|
||
| {/* Card */} | ||
| <div | ||
| className="w-full max-w-sm bg-card/80 border border-border rounded-2xl p-8 backdrop-blur-sm animate-slide-up" | ||
| style={{ animationDelay: "200ms" }} | ||
| > | ||
| {sent ? ( | ||
| <div role="alert" className="flex flex-col items-center text-center gap-4"> | ||
| <div className="w-12 h-12 rounded-full bg-accent-green/15 border border-accent-green/25 flex items-center justify-center"> | ||
| <CheckCircleIcon className="w-6 h-6 text-accent-green" strokeWidth={1.5} /> | ||
| </div> | ||
| <div> | ||
| <p className="text-sm font-semibold text-text-primary mb-1">Check your inbox</p> | ||
| <p className="text-xs text-text-muted leading-relaxed"> | ||
| An email with password reset instructions has been sent to your | ||
| registered email address. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| ) : ( | ||
| <form onSubmit={handleSubmit} className="space-y-5"> | ||
| <div> | ||
| <label | ||
| htmlFor="account" | ||
| className="block text-2xs font-mono font-semibold uppercase tracking-label text-text-muted mb-2.5" | ||
| > | ||
| Username or email address | ||
| </label> | ||
| <input | ||
| id="account" | ||
| type="text" | ||
| value={account} | ||
| onChange={(e) => setAccount(e.target.value)} | ||
| required | ||
| autoFocus | ||
| autoComplete="username" | ||
| className="w-full px-4 py-3 bg-background border border-border rounded-lg text-sm text-text-primary font-mono placeholder:text-text-secondary focus:outline-none focus:border-primary/50 focus:ring-1 focus:ring-primary/20 transition-all duration-200" | ||
| placeholder="username or email" | ||
| /> | ||
| </div> | ||
|
|
||
| <button | ||
| type="submit" | ||
| disabled={loading || !account.trim()} | ||
| className="w-full bg-primary hover:bg-primary-600 text-white py-3 px-4 rounded-lg text-sm font-semibold disabled:opacity-dim disabled:cursor-not-allowed transition-all duration-200 mt-1 flex items-center justify-center gap-2" | ||
| > | ||
| {loading ? ( | ||
| <> | ||
| <span className="w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin" /> | ||
| <span className="font-mono text-xs">Sending...</span> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <EnvelopeIcon className="w-4 h-4" strokeWidth={2} /> | ||
| Reset Password | ||
| </> | ||
| )} | ||
| </button> | ||
| </form> | ||
| )} | ||
| </div> | ||
|
|
||
| {/* Back to login */} | ||
| <div | ||
| className="mt-8 animate-fade-in" | ||
| style={{ animationDelay: "600ms" }} | ||
| > | ||
| <Link | ||
| to="/login" | ||
| className="text-xs text-text-muted hover:text-text-secondary transition-colors" | ||
| > | ||
| ← Back to login | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.