Add missing error on authentication

This commit is contained in:
Anthony Laibe 2018-10-19 10:59:30 +01:00 committed by Pascal Precht
parent 4ca753f38f
commit 02aea0506f
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 18 additions and 17 deletions

View File

@ -24,6 +24,9 @@ class Login extends React.Component {
<div className="login-container d-flex flex-column-reverse flex-md-row"> <div className="login-container d-flex flex-column-reverse flex-md-row">
<div className="login-layout-container-section flex-fill"> <div className="login-layout-container-section flex-fill">
<h2>Login</h2> <h2>Login</h2>
{this.props.error &&
<p className="text-danger">{this.props.error}</p>
}
<div className="mt-4"> <div className="mt-4">
<form onSubmit={(e) => this.handleSubmit(e)}> <form onSubmit={(e) => this.handleSubmit(e)}>
<div className="form-group"> <div className="form-group">

View File

@ -75,25 +75,23 @@ class AppContainer extends Component {
} }
} }
render() { renderBody() {
let content;
if (this.shouldRenderLogin()) { if (this.shouldRenderLogin()) {
content = <Login credentials={this.props.credentials} authenticate={this.props.authenticate} error={this.props.authenticationError} />; return <Login credentials={this.props.credentials} authenticate={this.props.authenticate} error={this.props.authenticationError} />;
} else {
content = <Layout location={this.props.location}
logout={this.props.logout}
toggleTheme={() => this.toggleTheme()}
currentTheme={this.props.theme}>
<React.Fragment>{routes}</React.Fragment>
</Layout>;
} }
return ( return (
<div className={(this.props.theme) + "-theme"}> <Layout location={this.props.location}
{content} logout={this.props.logout}
</div> toggleTheme={() => this.toggleTheme()}
currentTheme={this.props.theme}>
<React.Fragment>{routes}</React.Fragment>
</Layout>
); );
} }
render() {
return <div className={(this.props.theme) + "-theme"}>{this.renderBody()}</div>;
}
} }
AppContainer.propTypes = { AppContainer.propTypes = {
@ -111,7 +109,7 @@ AppContainer.propTypes = {
location: PropTypes.object, location: PropTypes.object,
theme: PropTypes.string, theme: PropTypes.string,
changeTheme: PropTypes.func, changeTheme: PropTypes.func,
fetchTheme: PropTypes.func fetchTheme: PropTypes.func,
}; };
function mapStateToProps(state) { function mapStateToProps(state) {
@ -119,7 +117,7 @@ function mapStateToProps(state) {
initialized: getVersions(state).length > 0, initialized: getVersions(state).length > 0,
credentials: getCredentials(state), credentials: getCredentials(state),
authenticationError: getAuthenticationError(state), authenticationError: getAuthenticationError(state),
theme: getTheme(state) theme: getTheme(state),
}; };
} }

View File

@ -14,7 +14,7 @@ function *doRequest(entity, serviceFn, payload) {
if(response) { if(response) {
yield put(entity.success(response.data, payload)); yield put(entity.success(response.data, payload));
} else if (error) { } else if (error) {
yield put(entity.failure(error.message)); yield put(entity.failure(error.message || error));
} }
} }