equal
deleted
inserted
replaced
1 import Immutable from 'immutable'; |
1 import Immutable from 'immutable'; |
2 import * as types from '../constants/actionTypes'; |
2 import * as types from '../constants/actionTypes'; |
3 import UserRecord from '../store/userRecord'; |
3 import UserRecord from '../store/userRecord'; |
|
4 import asyncRequest from '../constants/asyncRequest'; |
4 |
5 |
5 export const isAuthenticated = (state = false, action) => { |
6 export const isAuthenticated = (state = false, action) => { |
6 switch (action.type) { |
7 switch (action.type) { |
7 case types.AUTH_DEAUTHENTICATE: |
8 case types.AUTH_DEAUTHENTICATE: |
8 case types.AUTH_LOGOUT: |
9 case types.AUTH_LOGOUT: |
41 default: |
42 default: |
42 return state; |
43 return state; |
43 } |
44 } |
44 } |
45 } |
45 |
46 |
46 const loginState = Immutable.Map({ |
47 export const login = (state = asyncRequest, action) => { |
47 loading: false, |
|
48 success: false, |
|
49 error: false, |
|
50 errorMessages: Immutable.Map({}) |
|
51 }); |
|
52 |
|
53 export const login = (state = loginState, action) => { |
|
54 switch (action.type) { |
48 switch (action.type) { |
55 case types.AUTH_LOGIN_REQUEST: |
49 case types.AUTH_LOGIN_REQUEST: |
56 return Immutable.Map({ |
50 return Immutable.Map({ |
57 loading: true, |
51 loading: true, |
58 success: false, |
52 success: false, |
69 default: |
63 default: |
70 return state |
64 return state |
71 } |
65 } |
72 } |
66 } |
73 |
67 |
74 const registerState = Immutable.Map({ |
68 export const register = (state = asyncRequest, action) => { |
75 loading: false, |
|
76 success: false, |
|
77 error: false, |
|
78 errorMessages: Immutable.Map({}) |
|
79 }); |
|
80 |
|
81 export const register = (state = registerState, action) => { |
|
82 switch (action.type) { |
69 switch (action.type) { |
83 case types.AUTH_REGISTER_REQUEST: |
70 case types.AUTH_REGISTER_REQUEST: |
84 return Immutable.Map({ |
71 return Immutable.Map({ |
85 loading: true, |
72 loading: true, |
86 success: false, |
73 success: false, |