add client side password confirmation check
This commit is contained in:
parent
653260b2fc
commit
bd1c90da99
3 changed files with 32 additions and 3 deletions
|
@ -11,6 +11,14 @@ const Signup = (props) => {
|
|||
|
||||
const handleSubmit = async e => {
|
||||
e.preventDefault();
|
||||
if (password !== confirmPassword) {
|
||||
return props.dispatch({
|
||||
type: 'ERR',
|
||||
message: 'AUTH_ERROR',
|
||||
body: { authError: 'Password fields must be the same'}
|
||||
})
|
||||
}
|
||||
|
||||
const signupResponse = await authServices.signupService({
|
||||
username,
|
||||
email,
|
||||
|
|
17
play-node-go/src/reducers/err/stateReducer.err.js
Normal file
17
play-node-go/src/reducers/err/stateReducer.err.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
// @flow
|
||||
import type { state, action } from '../stateReducer';
|
||||
|
||||
export const errorReducer = (state: state, action: action):state => {
|
||||
switch (action.message) {
|
||||
case 'AUTH_ERROR':
|
||||
return authErrorReducer(state, action);
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
function authErrorReducer(state: state, action: action): state {
|
||||
const auth = action.body.authError;
|
||||
return {...state, errors: {auth} };
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// @flow
|
||||
import { initState } from './init/stateReducer.init';
|
||||
import { authReducer } from './auth/stateReducer.auth';
|
||||
import { errorReducer } from './err/stateReducer.err';
|
||||
import { indexReducer } from './index/stateReducer.index';
|
||||
|
||||
export type state = {
|
||||
|
@ -19,13 +20,16 @@ export const stateReducer = (state: state, action: action): state => {
|
|||
|
||||
switch (action.type) {
|
||||
case 'INIT': return initState();
|
||||
|
||||
case 'AUTH':
|
||||
return authReducer(errorStrippedState, action);
|
||||
|
||||
case 'INDEX':
|
||||
return indexReducer(errorStrippedState, action);
|
||||
|
||||
case 'AUTH':
|
||||
return authReducer(errorStrippedState, action);
|
||||
|
||||
case 'ERR':
|
||||
return errorReducer(errorStrippedState, action);
|
||||
|
||||
default: return state;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue