style(dashboard-v2): unify password schemas
This commit is contained in:
parent
2664a3c4c4
commit
6b733ab739
|
@ -1,24 +1,19 @@
|
|||
import PropTypes from "prop-types";
|
||||
import { Formik, Form } from "formik";
|
||||
import * as Yup from "yup";
|
||||
|
||||
import { TextField } from "../Form/TextField";
|
||||
import { Button } from "../Button";
|
||||
import { passwordSchema } from "./SignUpForm";
|
||||
|
||||
import accountsService from "../../services/accountsService";
|
||||
|
||||
const resetPasswordSchema = Yup.object().shape({
|
||||
password: Yup.string().required("Password is required").min(6, "Password has to be at least 6 characters long"),
|
||||
confirmPassword: Yup.string().oneOf([Yup.ref("password"), null], "Passwords must match"),
|
||||
});
|
||||
|
||||
export const ResetPasswordForm = ({ token, onSuccess, onFailure }) => (
|
||||
<Formik
|
||||
initialValues={{
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
}}
|
||||
validationSchema={resetPasswordSchema}
|
||||
validationSchema={passwordSchema}
|
||||
onSubmit={async ({ password, confirmPassword }) => {
|
||||
try {
|
||||
await accountsService.post("user/recover", {
|
||||
|
|
|
@ -7,13 +7,19 @@ import { Button } from "../Button";
|
|||
|
||||
import accountsService from "../../services/accountsService";
|
||||
|
||||
// TODO: better password strength validation
|
||||
const registrationSchema = Yup.object().shape({
|
||||
email: Yup.string().required("Email is required").email("Please provide a valid email address"),
|
||||
password: Yup.string().required("Password is required").min(6, "Password has to be at least 6 characters long"),
|
||||
confirmPassword: Yup.string().oneOf([Yup.ref("password"), null], "Passwords must match"),
|
||||
export const passwordSchema = Yup.object().shape({
|
||||
password: Yup.string().required("Password is required"),
|
||||
confirmPassword: Yup.string()
|
||||
.oneOf([Yup.ref("password"), null], "Passwords must match")
|
||||
.required("Please re-type your password"),
|
||||
});
|
||||
|
||||
const registrationSchema = Yup.object()
|
||||
.shape({
|
||||
email: Yup.string().required("Email is required").email("Please provide a valid email address"),
|
||||
})
|
||||
.concat(passwordSchema);
|
||||
|
||||
const USER_EXISTS_ERROR = "identity already belongs to an existing user";
|
||||
|
||||
export const SignUpForm = ({ onSuccess, onFailure }) => (
|
||||
|
@ -77,12 +83,6 @@ export const SignUpForm = ({ onSuccess, onFailure }) => (
|
|||
error={errors.password}
|
||||
touched={touched.password}
|
||||
/>
|
||||
<div className="text-xs text-palette-400">
|
||||
<ul>
|
||||
<li>At least 6 characters long</li>
|
||||
<li>Significantly different from the email</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<TextField
|
||||
type="password"
|
||||
|
|
Reference in New Issue