-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove redis * continuing work-in-progress * move some stuff around * more wip * misc clean uip * Refactor get_user_id_from_session_token into get_user_from_jwt The function get_user_from_jwt is unimplemented but I have left a comment stating how it should be implemented. In particular, we ought to throw an error if the JWT is not associated with a user. Furthermore, I have replaced every instance of user_id with id. * Fix circular import with TABLE_NAME * replace new_token fns with appropriate jwt generation placeholders * unify oauthuser with normal user model * Revert "replace new_token fns with appropriate jwt generation placeholders" We are not using JWT's. We are going to use API keys anyway, which makes JWTs completely pointless. This reverts commit b66d8ad. * remove calls to get_api_key fn that isn't doing anything * get rid of jwts for good and format stuff * fix all mypy errors except for weird GitHub id thing almost done with boilerplate * fix lints for real by adding new custom exception * Make email field optional * some stuff * model schema changes * clean up * clean up some stuff * Just have type of auth_keys be list[str] for User No one is going to voluntarily pass in auth_keys=None. We ought to just make the default value the empty list rather than None, since that is how it is passed into the constructor in the first place * Get rid of email-password login. We are transitioning into using OAuth exclusively. * Remove frontend pages associated with email/password login * Fix accidental change of GitHub login URL * Almost-working everything except User creation in model.py * Fix OAuth GitHub * Re-implement parts query * Lints * Add /robots route by genericing /parts route * format * Actually add robot routers, oops. * Delete unnecessary items_per_page in robots.py We moved it to BaseCrud * actually call the right function oops * Restore image uploading functionality * Make OAUTH Keys work * lints and format * Remove frontend sidebar/api cruft We no longer use email/password sign-in on the backend; change the frontend to reflect that. * Fix image display in frontend * Fix user owner display Involves fixing batch query too. * dont accidentally delete user id WHEN EDITING ROBOT * Properly display listing owner information * Adjust misleading router function names * fix Your Robots/Your Parts queries * remove unused Sidebar.tsx imports * Split up GitHub router's GitHub API calls This is solely to make it possible to mock them in unit tests. * format * Make unit tests work with new auth system/backend * remove bespoke field_info stuff It was causing bugs /shrug * Add lints to tests (and have tests pass them too) * fix lint --------- Co-authored-by: Dennis Chen <[email protected]>
- Loading branch information
1 parent
de5029a
commit dbaf6fd
Showing
46 changed files
with
843 additions
and
1,787 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
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,9 +1,4 @@ | ||
import TCButton from "components/files/TCButton"; | ||
import { useAlertQueue } from "hooks/alerts"; | ||
import { api } from "hooks/api"; | ||
import { useAuthentication } from "hooks/auth"; | ||
import { FormEvent, useState } from "react"; | ||
import { Col, Form, Offcanvas, Row } from "react-bootstrap"; | ||
import { Col, Offcanvas, Row } from "react-bootstrap"; | ||
import { Link } from "react-router-dom"; | ||
|
||
interface Props { | ||
|
@@ -12,46 +7,6 @@ interface Props { | |
} | ||
|
||
const Sidebar = ({ show, onHide }: Props) => { | ||
const { addAlert } = useAlertQueue(); | ||
|
||
const auth = useAuthentication(); | ||
const auth_api = new api(auth.api); | ||
|
||
const [newEmail, setNewEmail] = useState<string>(""); | ||
const [changeEmailSuccess, setChangeEmailSuccess] = useState<boolean>(false); | ||
const [oldPassword, setOldPassword] = useState<string>(""); | ||
const [newPassword, setNewPassword] = useState<string>(""); | ||
const [changePasswordSuccess, setChangePasswordSuccess] = | ||
useState<boolean>(false); | ||
|
||
const sendChangeEmail = async (event: FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
try { | ||
await auth_api.send_change_email(newEmail); | ||
setChangeEmailSuccess(true); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
addAlert(error.message, "error"); | ||
} else { | ||
addAlert("Unexpected error when trying to change email", "error"); | ||
} | ||
} | ||
}; | ||
|
||
const changePassword = async (event: FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
try { | ||
await auth_api.change_password(oldPassword, newPassword); | ||
setChangePasswordSuccess(true); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
addAlert(error.message, "error"); | ||
} else { | ||
addAlert("Unexpected error when trying to change password", "error"); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<Offcanvas show={show} onHide={onHide} placement="end"> | ||
<Offcanvas.Header closeButton> | ||
|
@@ -65,78 +20,6 @@ const Sidebar = ({ show, onHide }: Props) => { | |
height: "100%", | ||
}} | ||
> | ||
<Row> | ||
<p> | ||
<strong>Change Email</strong> | ||
</p> | ||
{auth.email == "[email protected]" ? ( | ||
<p> | ||
No email address associated with this account. (This is because | ||
you registered via OAuth.) | ||
</p> | ||
) : ( | ||
<p>Current email: {auth.email}</p> | ||
)} | ||
{changeEmailSuccess ? ( | ||
<p>An email has been sent to your new email address.</p> | ||
) : ( | ||
<Form onSubmit={sendChangeEmail}> | ||
<label htmlFor="new-email">New email</label> | ||
<Form.Control | ||
id="new-email" | ||
autoComplete="email" | ||
className="mb-3" | ||
type="text" | ||
onChange={(e) => { | ||
setNewEmail(e.target.value); | ||
}} | ||
value={newEmail} | ||
required | ||
/> | ||
<TCButton type="submit">Change Email</TCButton> | ||
</Form> | ||
)} | ||
</Row> | ||
<Row> | ||
<p> | ||
<strong>Change Password</strong> | ||
</p> | ||
<p> | ||
You may only change your password if you have a previous password. | ||
If not, log out and reset your password. | ||
</p> | ||
{changePasswordSuccess ? ( | ||
<p>Your password has been changed.</p> | ||
) : ( | ||
<Form onSubmit={changePassword}> | ||
<label htmlFor="old-password">Old password</label> | ||
<Form.Control | ||
id="old-password" | ||
autoComplete="current-password" | ||
className="mb-3" | ||
type="password" | ||
onChange={(e) => { | ||
setOldPassword(e.target.value); | ||
}} | ||
value={oldPassword} | ||
required | ||
/> | ||
<label htmlFor="new-password">New password</label> | ||
<Form.Control | ||
id="new-password" | ||
autoComplete="new-password" | ||
className="mb-3" | ||
type="password" | ||
onChange={(e) => { | ||
setNewPassword(e.target.value); | ||
}} | ||
value={newPassword} | ||
required | ||
/> | ||
<TCButton type="submit">Change Password</TCButton> | ||
</Form> | ||
)} | ||
</Row> | ||
<Row style={{ marginTop: "auto" }} /> | ||
<Row> | ||
<Link to="/about">About</Link> | ||
|
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
Oops, something went wrong.