- Notifications
You must be signed in to change notification settings - Fork928
fix: prevent email from being altered#1863
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
It'd be nice if you removed the frontend in this PR too. It'd be good to build the habit of not having broken states in our main deployment.
I'm happy to help if you encounter any issues. That's not a blocker though, just a suggestion!
BrunoQuaresma commentedMay 27, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@f0ssel feel free to do the FE if you want but if not, which is 100% ok, could you create a ticket for this and add the FE label, and make it Community MVP, please? |
💯 I would not merge this as is, frontend will be same PR |
@BrunoQuaresma This is ready for frontend review |
FE ticket is here:#1725 |
@@ -59,6 +56,7 @@ export const AccountForm: React.FC<AccountFormProps> = ({ | |||
fullWidth | |||
label={Language.emailLabel} | |||
variant="outlined" | |||
disabled={true} |
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.
disabled={true} | |
disabled |
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.
I feel like we should remove thegetFieldHelpers("email")
andonChange
andautoComplete
here.
At a minimum, can you remove theautoComplete
(doesn't make much sense for adisabled
field).
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.
Here's a patch I'd prefer to be applied to the FE code. It cleans up the form so thatemail
is read-only and not associated with theFormik
form.
diff --git a/site/src/components/SettingsAccountForm/SettingsAccountForm.tsx b/site/src/components/SettingsAccountForm/SettingsAccountForm.tsxindex 3773b307..4c90deb6 100644--- a/site/src/components/SettingsAccountForm/SettingsAccountForm.tsx+++ b/site/src/components/SettingsAccountForm/SettingsAccountForm.tsx@@ -8,7 +8,6 @@ import { LoadingButton } from "../LoadingButton/LoadingButton" import { Stack } from "../Stack/Stack" interface AccountFormValues {- email: string username: string }@@ -23,7 +22,9 @@ const validationSchema = Yup.object({ }) export type AccountFormErrors = FormikErrors<AccountFormValues>+ export interface AccountFormProps {+ email: string isLoading: boolean initialValues: AccountFormValues onSubmit: (values: AccountFormValues) => void@@ -32,6 +33,7 @@ export interface AccountFormProps { } export const AccountForm: React.FC<AccountFormProps> = ({+ email, isLoading, onSubmit, initialValues,@@ -49,15 +51,7 @@ export const AccountForm: React.FC<AccountFormProps> = ({ <> <form onSubmit={form.handleSubmit}> <Stack>- <TextField- {...getFieldHelpers("email")}- onChange={onChangeTrimmed(form)}- autoComplete="email"- fullWidth- label={Language.emailLabel}- variant="outlined"- disabled={true}- />+ <TextField disabled fullWidth label={Language.emailLabel} value={email} variant="outlined" /> <TextField {...getFieldHelpers("username")} onChange={onChangeTrimmed(form)}diff --git a/site/src/pages/SettingsPages/AccountPage/AccountPage.tsx b/site/src/pages/SettingsPages/AccountPage/AccountPage.tsxindex 5f9cf428..5954ac64 100644--- a/site/src/pages/SettingsPages/AccountPage/AccountPage.tsx+++ b/site/src/pages/SettingsPages/AccountPage/AccountPage.tsx@@ -26,10 +26,11 @@ export const AccountPage: React.FC = () => { return ( <Section title={Language.title}> <AccountForm+ email={me.email} error={hasUnknownError ? Language.unknownError : undefined} formErrors={formErrors} isLoading={authState.matches("signedIn.profile.updatingProfile")}- initialValues={{ username: me.username, email: me.email }}+ initialValues={{ username: me.username }} onSubmit={(data) => { authSend({ type: "UPDATE_PROFILE",
Uh oh!
There was an error while loading.Please reload this page.
Fixes:#1490
Fixes:#1725