Skip to content

Instantly share code, notes, and snippets.

@sivadass
Created January 31, 2018 10:50
Show Gist options
  • Save sivadass/0680a87d9b4fc9fba773a759ffeb898b to your computer and use it in GitHub Desktop.
Save sivadass/0680a87d9b4fc9fba773a759ffeb898b to your computer and use it in GitHub Desktop.
Action Type
// There are three possible states for our login
// process and we need actions for each of them
export const LOGIN_REQUEST = 'LOGIN_REQUEST'
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'
export const LOGIN_FAILURE = 'LOGIN_FAILURE'
function requestLogin(creds) {
return {
type: LOGIN_REQUEST,
isFetching: true,
isAuthenticated: false,
creds
}
}
function receiveLogin(user) {
return {
type: LOGIN_SUCCESS,
isFetching: false,
isAuthenticated: true,
id_token: user.id_token
}
}
function loginError(message) {
return {
type: LOGIN_FAILURE,
isFetching: false,
isAuthenticated: false,
message
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment