diff --git a/js/api.js b/js/api.js
index 1484cc9..afc81c7 100644
--- a/js/api.js
+++ b/js/api.js
@@ -21,6 +21,8 @@ const actiontypes_userinfo = {
'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS',
'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR',
+ 'CLEAR_ERRORS' : 'CLEAR_ERRORS',
+
'LOGOUT' : 'LOGOUT',
'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS',
@@ -221,6 +223,11 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
error : true,
errorMessages : action.parameters.errorMessages
});
+ case actiontypes_userinfo.CLEAR_ERRORS:
+ return Object.assign({}, state, {
+ error : false,
+ errorMessages : []
+ });
case actiontypes_userinfo.LOGOUT:
deleteRequest(action.state, '/users/sign_out').then(() => {
__store.dispatch({ type : actiontypes_userinfo.CLEAR });
@@ -357,6 +364,12 @@ export function verifyCredentials() {
}
}
+export function clearErrors() {
+ __store.dispatch({
+ type: actiontypes_userinfo.CLEAR_ERRORS
+ });
+}
+
export function register(username, email, password) {
__store.dispatch({
type: actiontypes_userinfo.REGISTER,
diff --git a/js/components/Login.js b/js/components/Login.js
index bfa99e4..174677b 100644
--- a/js/components/Login.js
+++ b/js/components/Login.js
@@ -3,7 +3,10 @@ import React from 'react';
import {connect} from 'react-redux';
import Router from 'next/router';
-import {login} from '../api';
+import {
+ login,
+ clearErrors
+} from '../api';
export function Login(props) {
return (
@@ -84,6 +87,10 @@ class LoginForm extends React.Component {
};
}
+ componentDidMount() {
+ clearErrors();
+ }
+
tryLogin(event) {
event.preventDefault();
login(this.state.email, this.state.password);
diff --git a/pages/register.js b/pages/register.js
index 75e1c2a..d655a5e 100644
--- a/pages/register.js
+++ b/pages/register.js
@@ -15,7 +15,10 @@ import {
import { TurniereNavigation } from '../js/components/Navigation';
import { Footer } from '../js/components/Footer';
-import { register } from '../js/api';
+import {
+ register,
+ clearErrors
+} from '../js/api';
import '../static/everypage.css';
@@ -38,20 +41,27 @@ export default class RegisterPage extends React.Component {
}
}
-function Register() {
- return (
-
-
-
- Account anlegen
-
-
-
-
-
- );
+class Register extends React.Component {
+
+ componentDidMount() {
+ clearErrors();
+ }
+
+ render() {
+ return (
+
+
+
+ Account anlegen
+
+
+
+
+
+ );
+ }
}
class RegisterErrorList extends React.Component {
@@ -151,4 +161,4 @@ function AccountRequirementMarketing() {
);
-}
\ No newline at end of file
+}