Skip to content

Commit

Permalink
Stop using logout when no locally stored user was found.
Browse files Browse the repository at this point in the history
This was causing users to not be able to sign up with Netlify Identity.
  • Loading branch information
tech4him1 authored and erquhart committed Nov 11, 2017
1 parent 0f8a74b commit d378488
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { notifSend } = notifActions;
export const AUTH_REQUEST = 'AUTH_REQUEST';
export const AUTH_SUCCESS = 'AUTH_SUCCESS';
export const AUTH_FAILURE = 'AUTH_FAILURE';
export const AUTH_REQUEST_DONE = 'AUTH_REQUEST_DONE';
export const LOGOUT = 'LOGOUT';

export function authenticating() {
Expand All @@ -29,6 +30,12 @@ export function authError(error) {
};
}

export function doneAuthenticating() {
return {
type: AUTH_REQUEST_DONE,
};
}

export function logout() {
return {
type: LOGOUT,
Expand All @@ -46,7 +53,7 @@ export function authenticateUser() {
if (user) {
dispatch(authenticate(user));
} else {
dispatch(logoutUser());
dispatch(doneAuthenticating());
}
})
.catch((error) => {
Expand Down
4 changes: 3 additions & 1 deletion src/reducers/auth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Immutable from 'immutable';
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, LOGOUT } from '../actions/auth';
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, AUTH_REQUEST_DONE, LOGOUT } from '../actions/auth';

const auth = (state = null, action) => {
switch (action.type) {
Expand All @@ -9,6 +9,8 @@ const auth = (state = null, action) => {
return Immutable.fromJS({ user: action.payload });
case AUTH_FAILURE:
return Immutable.Map({ error: action.payload.toString() });
case AUTH_REQUEST_DONE:
return state.remove('isFetching');
case LOGOUT:
return state.remove('user').remove('isFetching');
default:
Expand Down

0 comments on commit d378488

Please sign in to comment.