diff --git a/Automation/src/test/java/Utils.java b/Automation/src/test/java/Utils.java index 149e3ef2a537ce9178435b50ab619a8ee59c5095..74b8cb31429e4f0b97371b0b00b5f9b8b1c78064 100644 --- a/Automation/src/test/java/Utils.java +++ b/Automation/src/test/java/Utils.java @@ -81,7 +81,7 @@ public class Utils { driver.findElement(By.name("email")).sendKeys(email); driver.findElement(By.name("password")).sendKeys(password); - driver.findElement(By.name("confirmPassword")).sendKeys(password); + driver.findElement(By.name("confirmNewPassword")).sendKeys(password); driver.findElement(By.xpath(".//button[contains(text(),'"+"CONFIRM"+"')]")).click(); diff --git a/packages/component-faraday-ui/src/helpers/formValidators.js b/packages/component-faraday-ui/src/helpers/formValidators.js index 3007139196800247ef5057ea5da9e8c9eeb27e4d..b3a6f6a56d39df8c0ed49732ebf311291ea2cbe9 100644 --- a/packages/component-faraday-ui/src/helpers/formValidators.js +++ b/packages/component-faraday-ui/src/helpers/formValidators.js @@ -10,10 +10,10 @@ export const passwordValidator = values => { if (!values.password) { errors.password = 'Required' } - if (!values.confirmPassword) { - errors.confirmPassword = 'Required' - } else if (values.confirmPassword !== values.password) { - errors.confirmPassword = "Passwords don't match." + if (!values.confirmNewPassword) { + errors.confirmNewPassword = 'Required' + } else if (values.confirmNewPassword !== values.password) { + errors.confirmNewPassword = "Passwords don't match." } return errors diff --git a/packages/components-faraday/src/components/SignUp/ReviewerInviteDecision.js b/packages/components-faraday/src/components/SignUp/ReviewerInviteDecision.js index a7c1cbaea1d5633f7479879b168e5c29db1b82e8..5f11176ce1e93c3a15cfef9c6e080d97801544e9 100644 --- a/packages/components-faraday/src/components/SignUp/ReviewerInviteDecision.js +++ b/packages/components-faraday/src/components/SignUp/ReviewerInviteDecision.js @@ -1,15 +1,13 @@ import React from 'react' import { connect } from 'react-redux' import { reduxForm } from 'redux-form' -import { required, minChars } from 'xpub-validators' +// import { required, minChars } from 'xpub-validators' import { compose, withState, lifecycle } from 'recompose' import { loginUser } from 'pubsweet-component-login/actions' -import { Button, ValidatedField, H2, TextField, Spinner } from '@pubsweet/ui' +import { Button, H2, Spinner } from '@pubsweet/ui' import { Row, - Item, Text, - Label, ShadowedBox, handleError, withFetching, @@ -18,13 +16,11 @@ import { import { redirectToError } from '../utils' import { passwordValidator } from '../../../../component-faraday-ui/src/Utils' import { reviewerDecision, setReviewerPassword } from '../../redux/reviewers' +import PasswordValidation from '../../../../component-faraday-ui/src/PasswordValidation' const agreeText = `You have been invited to review a manuscript on the Hindawi platform. Please set a password and proceed to the manuscript.` const declineText = `You have decline to work on a manuscript.` -const PasswordField = input => <TextField {...input} type="password" /> -const min8Chars = minChars(8) - const ReviewerInviteDecision = ({ agree, error, @@ -44,27 +40,7 @@ const ReviewerInviteDecision = ({ <Text align="center">{agree === 'true' ? agreeText : declineText}</Text> </Row> - <Row mt={2}> - <Item vertical> - <Label required>Password</Label> - <ValidatedField - component={PasswordField} - name="password" - validate={[required, min8Chars]} - /> - </Item> - </Row> - - <Row mt={2}> - <Item vertical> - <Label required>Confirm password</Label> - <ValidatedField - component={PasswordField} - name="confirmPassword" - validate={[required]} - /> - </Item> - </Row> + <PasswordValidation formLabel="Password" formName="invite-reviewer" /> {fetchingError && ( <Row mt={2}> diff --git a/packages/components-faraday/src/components/SignUp/utils.js b/packages/components-faraday/src/components/SignUp/utils.js index 3a9fd998810f022e1f270db62c10ab020a8bf29b..b7cf7a37f3991b5b01254f063403143e417e09be 100644 --- a/packages/components-faraday/src/components/SignUp/utils.js +++ b/packages/components-faraday/src/components/SignUp/utils.js @@ -5,7 +5,11 @@ import { loginUser } from 'pubsweet-component-login/actions' import { handleFormError } from '../utils' -export const parseSignupAuthor = ({ token, confirmPassword, ...values }) => ({ +export const parseSignupAuthor = ({ + token, + confirmNewPassword, + ...values +}) => ({ ...values, }) @@ -28,7 +32,10 @@ export const login = (dispatch, values, history) => export const confirmUser = (email, token, history) => (values, dispatch) => { const request = { ...values, email, token } if (values) { - return create('/users/reset-password', omit(request, ['confirmPassword'])) + return create( + '/users/reset-password', + omit(request, ['confirmNewPassword']), + ) .then(r => { const { username } = r const { password } = values