-
-
Save AllGistsEqual/9d2da1da9ec29354690790e2e496b4ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const userMiddleware: Middleware = ({ dispatch }) => next => action => { | |
next(action) | |
if (attemptLogin.match(action)) { | |
const { email, password } = action.payload | |
login(email, password) | |
.then(() => dispatch(setLogin(email, false))) | |
.catch(err => dispatch(setLogout('denied', err.message))) | |
} | |
if (attemptSignUp.match(action)) { | |
const { email, password } = action.payload | |
createAccount(email, password) | |
.then(() => dispatch(setLogin(email, true))) | |
.catch(err => dispatch(setLogout('denied', err.message))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment