'use strict';
import _ from 'underscore';
import {
  LOGIN_SAVE_EMAIL,
  LOGIN_SAVE_PASSWORD,
  SIGNUP_SAVE_NAME,
  SIGNUP_SAVE_EMAIL,
  SIGNUP_SAVE_PASSWORD,
  API_LOGIN_REQUEST,
  API_LOGIN_SUCCESS,
  API_LOGIN_FAILURE,
  API_SIGNUP_REQUEST,
  API_SIGNUP_SUCCESS,
  API_SIGNUP_FAILURE,
  CREATE_ANONYMOUS_ID,
  LOGOUT
} from 'app/actions/auth';
import { initialAuthState } from 'app/constants';

export default function authState(state = initialAuthState, action) {
  switch (action.type) {
    case LOGIN_SAVE_EMAIL:
      return { ...state, email: action.email };
    case LOGIN_SAVE_PASSWORD:
      return { ...state, password: action.password };
    case SIGNUP_SAVE_NAME:
      return { ...state, newName: action.name };
    case SIGNUP_SAVE_EMAIL:
      return { ...state, newEmail: action.email };
    case SIGNUP_SAVE_PASSWORD:
      return { ...state, newPassword: action.password };
    case API_LOGIN_REQUEST:
    case API_SIGNUP_REQUEST:
      return {
        ...(_.omit(state, 'error')),
        isFetching: true
      };
    case API_LOGIN_SUCCESS:
      return {
        ...(_.omit(state, ['error', 'email', 'password'])),
        isFetching: false,
        user: action.user,
        token: action.token
      };
    case API_SIGNUP_SUCCESS:
      return {
        ...(_.omit(state, [
          'error',
          'newName',
          'newEmail',
          'newPassword'
        ])),
        isFetching: false,
        user: action.user,
        token: action.token
      };
    case API_LOGIN_FAILURE:
    case API_SIGNUP_FAILURE:
      return {
        ...state,
        isFetching: false,
        error: action.error
      };
    case CREATE_ANONYMOUS_ID:
      return {
        ...state,
        anonymousId: action.anonymousId
      };
    case LOGOUT:
      return initialAuthState;
  }

  return state;
}

@@ -1297,16 +1297,57 @@
 tate, %5B%0A
+          'email',%0A          'password',%0A
         

Remove email and password from redux state upon account creation