Merge pull request #13 from turniere/ticket/TURNIERE-121
Fix a bug with the errors persisting after reloading
This commit is contained in:
commit
317b48e438
13
js/api.js
13
js/api.js
|
|
@ -21,6 +21,8 @@ const actiontypes_userinfo = {
|
||||||
'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS',
|
'LOGIN_RESULT_SUCCESS' : 'LOGIN_RESULT_SUCCESS',
|
||||||
'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR',
|
'LOGIN_RESULT_ERROR' : 'LOGIN_RESULT_ERROR',
|
||||||
|
|
||||||
|
'CLEAR_ERRORS' : 'CLEAR_ERRORS',
|
||||||
|
|
||||||
'LOGOUT' : 'LOGOUT',
|
'LOGOUT' : 'LOGOUT',
|
||||||
|
|
||||||
'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS',
|
'VERIFY_CREDENTIALS' : 'VERIFY_CREDENTIALS',
|
||||||
|
|
@ -221,6 +223,11 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
||||||
error : true,
|
error : true,
|
||||||
errorMessages : action.parameters.errorMessages
|
errorMessages : action.parameters.errorMessages
|
||||||
});
|
});
|
||||||
|
case actiontypes_userinfo.CLEAR_ERRORS:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
error : false,
|
||||||
|
errorMessages : []
|
||||||
|
});
|
||||||
case actiontypes_userinfo.LOGOUT:
|
case actiontypes_userinfo.LOGOUT:
|
||||||
deleteRequest(action.state, '/users/sign_out').then(() => {
|
deleteRequest(action.state, '/users/sign_out').then(() => {
|
||||||
__store.dispatch({ type : actiontypes_userinfo.CLEAR });
|
__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) {
|
export function register(username, email, password) {
|
||||||
__store.dispatch({
|
__store.dispatch({
|
||||||
type: actiontypes_userinfo.REGISTER,
|
type: actiontypes_userinfo.REGISTER,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@ import React from 'react';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import Router from 'next/router';
|
import Router from 'next/router';
|
||||||
|
|
||||||
import {login} from '../api';
|
import {
|
||||||
|
login,
|
||||||
|
clearErrors
|
||||||
|
} from '../api';
|
||||||
|
|
||||||
export function Login(props) {
|
export function Login(props) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -84,6 +87,10 @@ class LoginForm extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
clearErrors();
|
||||||
|
}
|
||||||
|
|
||||||
tryLogin(event) {
|
tryLogin(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
login(this.state.email, this.state.password);
|
login(this.state.email, this.state.password);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ import {
|
||||||
|
|
||||||
import { TurniereNavigation } from '../js/components/Navigation';
|
import { TurniereNavigation } from '../js/components/Navigation';
|
||||||
import { Footer } from '../js/components/Footer';
|
import { Footer } from '../js/components/Footer';
|
||||||
import { register } from '../js/api';
|
import {
|
||||||
|
register,
|
||||||
|
clearErrors
|
||||||
|
} from '../js/api';
|
||||||
|
|
||||||
import '../static/everypage.css';
|
import '../static/everypage.css';
|
||||||
|
|
||||||
|
|
@ -38,20 +41,27 @@ export default class RegisterPage extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Register() {
|
class Register extends React.Component {
|
||||||
return (
|
|
||||||
<Container className="py-5">
|
componentDidMount() {
|
||||||
<Card className="shadow">
|
clearErrors();
|
||||||
<CardBody>
|
}
|
||||||
<h1 className="custom-font">Account anlegen</h1>
|
|
||||||
<RegisterForm/>
|
render() {
|
||||||
<div className="mt-3">
|
return (
|
||||||
<a href="/login" className="mr-3">Ich habe bereits einen Account!</a>
|
<Container className="py-5">
|
||||||
</div>
|
<Card className="shadow">
|
||||||
</CardBody>
|
<CardBody>
|
||||||
</Card>
|
<h1 className="custom-font">Account anlegen</h1>
|
||||||
</Container>
|
<RegisterForm/>
|
||||||
);
|
<div className="mt-3">
|
||||||
|
<a href="/login" className="mr-3">Ich habe bereits einen Account!</a>
|
||||||
|
</div>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RegisterErrorList extends React.Component {
|
class RegisterErrorList extends React.Component {
|
||||||
|
|
@ -151,4 +161,4 @@ function AccountRequirementMarketing() {
|
||||||
</Card>
|
</Card>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue