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 import asyncRequest from '../constants/asyncRequest'; |
|
5 import uuidV4 from 'uuid/v4'; |
5 |
6 |
6 export const isAuthenticated = (state = false, action) => { |
7 export const isAuthenticated = (state = false, action) => { |
7 switch (action.type) { |
8 switch (action.type) { |
8 case types.AUTH_DEAUTHENTICATE: |
9 case types.AUTH_DEAUTHENTICATE: |
9 case types.AUTH_LOGOUT: |
10 case types.AUTH_LOGOUT: |
40 case types.AUTH_STORE_TOKEN: |
41 case types.AUTH_STORE_TOKEN: |
41 return action.token; |
42 return action.token; |
42 default: |
43 default: |
43 return state; |
44 return state; |
44 } |
45 } |
|
46 } |
|
47 |
|
48 export const clientId = (state = null, action) => { |
|
49 switch (action.type) { |
|
50 case types.AUTH_DEAUTHENTICATE: |
|
51 case types.AUTH_LOGOUT: |
|
52 return null; |
|
53 case types.AUTH_LOGIN_SUCCESS: |
|
54 return uuidV4(); |
|
55 default: |
|
56 return state; |
|
57 } |
|
58 |
45 } |
59 } |
46 |
60 |
47 export const login = (state = asyncRequest, action) => { |
61 export const login = (state = asyncRequest, action) => { |
48 switch (action.type) { |
62 switch (action.type) { |
49 case types.AUTH_LOGIN_REQUEST: |
63 case types.AUTH_LOGIN_REQUEST: |