-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: zkldi <20380519+zkldi@users.noreply.github.com>
- Loading branch information
1 parent
3683406
commit 0605927
Showing
172 changed files
with
4,766 additions
and
2,001 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,87 +1,80 @@ | ||
import { APIFetchV1 } from "util/api"; | ||
import { HistorySafeGoBack } from "util/misc"; | ||
import CenterPage from "components/util/CenterPage"; | ||
import SiteWordmark from "components/util/SiteWordmark"; | ||
import { Form, Col, Button } from "react-bootstrap"; | ||
import { Form, Button } from "react-bootstrap"; | ||
import React, { useState } from "react"; | ||
import { Link, useHistory } from "react-router-dom"; | ||
import MainPageTitleContainer from "components/util/MainPageTitleContainer"; | ||
import LoginPageLayout from "components/layout/LoginPageLayout"; | ||
|
||
export default function ForgotPasswordPage() { | ||
const [email, setEmail] = useState(""); | ||
const history = useHistory(); | ||
const [hasResetPassword, setHasResetPassword] = useState(false); | ||
|
||
return ( | ||
<CenterPage> | ||
<Col lg="6"> | ||
<MainPageTitleContainer | ||
title="Forgot Password" | ||
desc="Hey, it happens to all of us :P" | ||
/> | ||
{hasResetPassword ? ( | ||
<div> | ||
All good! An email has been sent to {email} IF an account exists with that | ||
email. | ||
<br /> | ||
<Link to="/">Go home.</Link> | ||
</div> | ||
) : ( | ||
<> | ||
<Form | ||
onSubmit={async (e) => { | ||
e.preventDefault(); | ||
<LoginPageLayout heading="Forgot Password" description="Hey, it happens to all of us :P"> | ||
{hasResetPassword ? ( | ||
<div> | ||
All good! An email has been sent to {email} IF an account exists with that | ||
email. | ||
<br /> | ||
<Link to="/">Go home.</Link> | ||
</div> | ||
) : ( | ||
<> | ||
<Form | ||
className="d-flex flex-column gap-4 w-100" | ||
onSubmit={async (e) => { | ||
e.preventDefault(); | ||
|
||
const res = await APIFetchV1( | ||
"/auth/forgot-password", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ email }), | ||
const res = await APIFetchV1( | ||
"/auth/forgot-password", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
true, | ||
true | ||
); | ||
body: JSON.stringify({ email }), | ||
}, | ||
true, | ||
true | ||
); | ||
|
||
if (res.success) { | ||
setTimeout(() => setHasResetPassword(true), 300); | ||
} | ||
}} | ||
> | ||
<Form.Group> | ||
<Form.Label>Email Address</Form.Label> | ||
<Form.Control | ||
type="email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
</Form.Group> | ||
<Form.Group className="justify-content-center d-flex pt-4"> | ||
<span | ||
onClick={() => HistorySafeGoBack(history)} | ||
tabIndex={4} | ||
className="mr-auto btn btn-outline-danger" | ||
> | ||
Back | ||
</span> | ||
<Button | ||
tabIndex={3} | ||
type="submit" | ||
className="ml-auto" | ||
disabled={email === ""} | ||
> | ||
Send Reset Link | ||
</Button> | ||
</Form.Group> | ||
</Form> | ||
<Link to="/screwed"> | ||
I signed up with a fake email, how can I recover my account? | ||
</Link> | ||
</> | ||
)} | ||
</Col> | ||
</CenterPage> | ||
if (res.success) { | ||
setTimeout(() => setHasResetPassword(true), 300); | ||
} | ||
}} | ||
> | ||
<Form.Group> | ||
<Form.Label>Email Address</Form.Label> | ||
<Form.Control | ||
type="email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
</Form.Group> | ||
<Form.Group className="justify-content-center d-flex pt-4"> | ||
<span | ||
onClick={() => HistorySafeGoBack(history)} | ||
tabIndex={4} | ||
className="me-auto btn btn-outline-danger" | ||
> | ||
Back | ||
</span> | ||
<Button | ||
tabIndex={3} | ||
type="submit" | ||
className="ms-auto" | ||
disabled={email === ""} | ||
> | ||
Send Reset Link | ||
</Button> | ||
</Form.Group> | ||
</Form> | ||
<Link to="/screwed"> | ||
I signed up with a fake email, how can I recover my account? | ||
</Link> | ||
</> | ||
)} | ||
</LoginPageLayout> | ||
); | ||
} |
Oops, something went wrong.