Sign in - revised error reporting
This commit is contained in:
@@ -13,37 +13,19 @@ import { storeCurrentEndpointKey } from "./configure";
|
||||
//import fetch from "../utils/fetch";
|
||||
|
||||
import { apiSignIn } from '../utils/api';
|
||||
import { makeActionCreator } from '../utils/actions';
|
||||
|
||||
import T from '../constants/ACTION_TYPES';
|
||||
|
||||
//import root from '../utils/root';
|
||||
|
||||
export function emailSignInFormUpdate(key, value) {
|
||||
return { type: T.AUTH.SIGN_IN_FORM_UPDATE, key, value };
|
||||
}
|
||||
|
||||
export function emailSignInStart() {
|
||||
return { type: T.AUTH.SIGN_IN_START };
|
||||
}
|
||||
|
||||
export function emailSignInComplete(user) {
|
||||
return { type: T.AUTH.SIGN_IN_COMPLETE, user };
|
||||
}
|
||||
|
||||
export function emailSignInError(errors) {
|
||||
return { type: T.AUTH.SIGN_IN_ERROR, errors };
|
||||
}
|
||||
export const emailSignInFormUpdate = makeActionCreator(T.AUTH.SIGN_IN_FORM_UPDATE, 'key', 'value');
|
||||
export const emailSignInStart = makeActionCreator(T.AUTH.SIGN_IN_START);
|
||||
export const emailSignInComplete = makeActionCreator(T.AUTH.SIGN_IN_COMPLETE, 'user');
|
||||
export const emailSignInError = makeActionCreator(T.AUTH.SIGN_IN_ERROR, 'error');
|
||||
|
||||
export function emailSignIn(body) {
|
||||
return dispatch => {
|
||||
// save previous endpoint key in case of failure
|
||||
//var prevEndpointKey = getCurrentEndpointKey();
|
||||
|
||||
// necessary for fetch to recognize the response as an api request
|
||||
//setCurrentEndpointKey(endpointKey);
|
||||
//var currentEndpointKey = getCurrentEndpointKey();
|
||||
//
|
||||
//dispatch(storeCurrentEndpointKey(currentEndpointKey));
|
||||
|
||||
dispatch(emailSignInStart());
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import read from '../../utils/readProp';
|
||||
import * as BS from "react-bootstrap";
|
||||
import Input from "./Input";
|
||||
import ButtonLoader from "./ButtonLoader";
|
||||
|
||||
import AuxErrorLabel from './AuxErrorLabel';
|
||||
|
||||
import { emailSignInFormUpdate, emailSignIn } from "../../actions/signIn";
|
||||
|
||||
@@ -63,10 +63,22 @@ class EmailSignInForm extends React.Component {
|
||||
|
||||
//const error = read(this.props.auth, 'signIn.errors.email', null);
|
||||
//debugger;
|
||||
const formErrors = read(this.props.auth, 'signIn.errors.errors', '');
|
||||
|
||||
return (
|
||||
|
||||
return (
|
||||
<form className='redux-auth email-sign-in-form clearfix'
|
||||
onSubmit={this.handleSubmit.bind(this)}>
|
||||
|
||||
<div className="form-group" style={{
|
||||
display: formErrors ? 'block' : 'none'
|
||||
}}>
|
||||
<AuxErrorLabel
|
||||
label="Form:"
|
||||
errors={formErrors.length ? [formErrors] : [] }
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Input type="text"
|
||||
className="email-sign-in-email"
|
||||
label="Email"
|
||||
|
||||
@@ -23,7 +23,7 @@ const createFormReducer = ([KEY_REQUEST, KEY_SUCCESS, KEY_ERROR, KEY_UPDATE]) =>
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
errors: Object.isSealed(error) ? { aggregate: error } : { ...error }
|
||||
errors: error
|
||||
}
|
||||
}
|
||||
case KEY_SUCCESS: {
|
||||
|
||||
Reference in New Issue
Block a user