This commit is contained in:
m5r
2021-08-01 22:03:49 +08:00
parent 7d34fcd48f
commit 1489f97c14
33 changed files with 147 additions and 313 deletions

View File

@ -30,20 +30,14 @@ export const LoginForm = (props: LoginFormProps) => {
} else {
return {
[FORM_ERROR]:
"Sorry, we had an unexpected error. Please try again. - " +
error.toString(),
"Sorry, we had an unexpected error. Please try again. - " + error.toString(),
};
}
}
}}
>
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField
name="password"
label="Password"
placeholder="Password"
type="password"
/>
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
<div>
<Link href={Routes.ForgotPasswordPage()}>
<a>Forgot your password?</a>

View File

@ -35,12 +35,7 @@ export const SignupForm = (props: SignupFormProps) => {
}}
>
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField
name="password"
label="Password"
placeholder="Password"
type="password"
/>
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
</Form>
</div>
);

View File

@ -17,9 +17,7 @@ jest.mock("preview-email", () => jest.fn());
describe.skip("forgotPassword mutation", () => {
it("does not throw error if user doesn't exist", async () => {
await expect(
forgotPassword({ email: "no-user@email.com" }, {} as Ctx),
).resolves.not.toThrow();
await expect(forgotPassword({ email: "no-user@email.com" }, {} as Ctx)).resolves.not.toThrow();
});
it("works correctly", async () => {

View File

@ -58,17 +58,11 @@ describe.skip("resetPassword mutation", () => {
// Expired token
await expect(
resetPassword(
{ token: expiredToken, password: newPassword, passwordConfirmation: newPassword },
mockCtx,
),
resetPassword({ token: expiredToken, password: newPassword, passwordConfirmation: newPassword }, mockCtx),
).rejects.toThrowError();
// Good token
await resetPassword(
{ token: goodToken, password: newPassword, passwordConfirmation: newPassword },
mockCtx,
);
await resetPassword({ token: goodToken, password: newPassword, passwordConfirmation: newPassword }, mockCtx);
// Delete's the token
const numberOfTokens = await db.token.count({ where: { userId: user.id } });
@ -76,8 +70,6 @@ describe.skip("resetPassword mutation", () => {
// Updates user's password
const updatedUser = await db.user.findFirst({ where: { id: user.id } });
expect(await SecurePassword.verify(updatedUser!.hashedPassword, newPassword)).toBe(
SecurePassword.VALID,
);
expect(await SecurePassword.verify(updatedUser!.hashedPassword, newPassword)).toBe(SecurePassword.VALID);
});
});

View File

@ -17,10 +17,7 @@ const ForgotPasswordPage: BlitzPage = () => {
{isSuccess ? (
<div>
<h2>Request Submitted</h2>
<p>
If your email is in our system, you will receive instructions to reset your
password shortly.
</p>
<p>If your email is in our system, you will receive instructions to reset your password shortly.</p>
</div>
) : (
<Form
@ -32,8 +29,7 @@ const ForgotPasswordPage: BlitzPage = () => {
await forgotPasswordMutation(values);
} catch (error) {
return {
[FORM_ERROR]:
"Sorry, we had an unexpected error. Please try again.",
[FORM_ERROR]: "Sorry, we had an unexpected error. Please try again.",
};
}
}}
@ -47,8 +43,6 @@ const ForgotPasswordPage: BlitzPage = () => {
ForgotPasswordPage.redirectAuthenticatedTo = Routes.Messages();
ForgotPasswordPage.getLayout = (page) => (
<BaseLayout title="Forgot Your Password?">{page}</BaseLayout>
);
ForgotPasswordPage.getLayout = (page) => <BaseLayout title="Forgot Your Password?">{page}</BaseLayout>;
export default ForgotPasswordPage;

View File

@ -41,19 +41,14 @@ const ResetPasswordPage: BlitzPage = () => {
};
} else {
return {
[FORM_ERROR]:
"Sorry, we had an unexpected error. Please try again.",
[FORM_ERROR]: "Sorry, we had an unexpected error. Please try again.",
};
}
}
}}
>
<LabeledTextField name="password" label="New Password" type="password" />
<LabeledTextField
name="passwordConfirmation"
label="Confirm New Password"
type="password"
/>
<LabeledTextField name="passwordConfirmation" label="Confirm New Password" type="password" />
</Form>
)}
</div>