diff --git a/src/actions/auth.js b/src/actions/auth.js index 10a586dd..477be7c9 100644 --- a/src/actions/auth.js +++ b/src/actions/auth.js @@ -43,7 +43,11 @@ export function authenticateUser() { dispatch(authenticating()); return backend.currentUser() .then((user) => { - if (user) dispatch(authenticate(user)); + if (user) { + dispatch(authenticate(user)); + } else { + dispatch(logoutUser()); + } }) .catch((error) => { dispatch(authError(error)); diff --git a/src/backends/git-gateway/AuthenticationPage.js b/src/backends/git-gateway/AuthenticationPage.js index c1cbc3e8..058030b3 100644 --- a/src/backends/git-gateway/AuthenticationPage.js +++ b/src/backends/git-gateway/AuthenticationPage.js @@ -54,6 +54,7 @@ export default class AuthenticationPage extends React.Component { static propTypes = { onLogin: PropTypes.func.isRequired, + inProgress: PropTypes.bool.isRequired, }; state = { email: "", password: "", errors: {} }; @@ -90,7 +91,7 @@ export default class AuthenticationPage extends React.Component { render() { const { errors } = this.state; - const { error } = this.props; + const { error, inProgress } = this.props; if (window.netlifyIdentity) { return
@@ -131,8 +132,9 @@ export default class AuthenticationPage extends React.Component { diff --git a/src/backends/github/AuthenticationPage.js b/src/backends/github/AuthenticationPage.js index e7c1a0ac..71ec7a06 100644 --- a/src/backends/github/AuthenticationPage.js +++ b/src/backends/github/AuthenticationPage.js @@ -9,6 +9,7 @@ import { Toast } from '../../components/UI/index'; export default class AuthenticationPage extends React.Component { static propTypes = { onLogin: PropTypes.func.isRequired, + inProgress: PropTypes.bool.isRequired, }; state = {}; @@ -32,6 +33,7 @@ export default class AuthenticationPage extends React.Component { render() { const { loginError } = this.state; + const { inProgress } = this.props; return (
@@ -40,9 +42,10 @@ export default class AuthenticationPage extends React.Component {
); diff --git a/src/backends/test-repo/AuthenticationPage.js b/src/backends/test-repo/AuthenticationPage.js index ad1aa5d0..17c5d77f 100644 --- a/src/backends/test-repo/AuthenticationPage.js +++ b/src/backends/test-repo/AuthenticationPage.js @@ -8,6 +8,7 @@ import logo from "../git-gateway/netlify_logo.svg"; export default class AuthenticationPage extends React.Component { static propTypes = { onLogin: PropTypes.func.isRequired, + inProgress: PropTypes.bool.isRequired, }; state = { email: '' }; @@ -22,6 +23,8 @@ export default class AuthenticationPage extends React.Component { }; render() { + const { inProgress } = this.props; + return (
@@ -36,9 +39,10 @@ export default class AuthenticationPage extends React.Component {
); diff --git a/src/containers/App.js b/src/containers/App.js index f66668ee..fff36c14 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -88,7 +88,7 @@ class App extends React.Component { React.createElement(backend.authComponent(), { onLogin: this.handleLogin.bind(this), error: auth && auth.get('error'), - isFetching: auth && auth.get('isFetching'), + inProgress: (auth && auth.get('isFetching')) || false, siteId: this.props.config.getIn(["backend", "site_domain"]), base_url: this.props.config.getIn(["backend", "base_url"], null) }) diff --git a/src/reducers/auth.js b/src/reducers/auth.js index c5f83de3..93a62cb3 100644 --- a/src/reducers/auth.js +++ b/src/reducers/auth.js @@ -10,7 +10,7 @@ const auth = (state = null, action) => { case AUTH_FAILURE: return Immutable.Map({ error: action.payload.toString() }); case LOGOUT: - return state.remove('user'); + return state.remove('user').remove('isFetching'); default: return state; }