Merge pull request #21 from turniere/ticket/TURNIERE-156
Fix bug "Login and Register pages don't clear the errors after switching page / reloading"
This commit is contained in:
commit
e76840de21
15
js/api.js
15
js/api.js
|
|
@ -21,8 +21,6 @@ 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',
|
||||||
|
|
@ -235,11 +233,6 @@ 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(() => {
|
||||||
action.parameters.successCallback();
|
action.parameters.successCallback();
|
||||||
|
|
@ -263,7 +256,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
||||||
});
|
});
|
||||||
return Object.assign({}, state, {});
|
return Object.assign({}, state, {});
|
||||||
case actiontypes_userinfo.REHYDRATE:
|
case actiontypes_userinfo.REHYDRATE:
|
||||||
return Object.assign({}, state, action.parameters);
|
return Object.assign({}, state, action.parameters, { error: false, errorMessages: [] });
|
||||||
case actiontypes_userinfo.CLEAR:
|
case actiontypes_userinfo.CLEAR:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
isSignedIn : false,
|
isSignedIn : false,
|
||||||
|
|
@ -406,12 +399,6 @@ 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,10 +3,7 @@ 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 {
|
import { login } from '../api';
|
||||||
login,
|
|
||||||
clearErrors
|
|
||||||
} from '../api';
|
|
||||||
|
|
||||||
import '../../static/css/errormessages.css';
|
import '../../static/css/errormessages.css';
|
||||||
import {notify} from 'react-notify-toast';
|
import {notify} from 'react-notify-toast';
|
||||||
|
|
@ -85,10 +82,6 @@ class LoginForm extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
clearErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
tryLogin(event) {
|
tryLogin(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
login(this.state.email, this.state.password, (username) => notify.show('Willkommen, ' + username + '!', 'success', 2500));
|
login(this.state.email, this.state.password, (username) => notify.show('Willkommen, ' + username + '!', 'success', 2500));
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@ 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 {
|
import { register } from '../js/api';
|
||||||
register,
|
|
||||||
clearErrors
|
|
||||||
} from '../js/api';
|
|
||||||
|
|
||||||
import '../static/css/errormessages.css';
|
import '../static/css/errormessages.css';
|
||||||
import '../static/everypage.css';
|
import '../static/everypage.css';
|
||||||
|
|
@ -42,9 +39,6 @@ export default class RegisterPage extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Register extends React.Component {
|
class Register extends React.Component {
|
||||||
componentDidMount() {
|
|
||||||
clearErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue