diff options
author | Michael Foiani <mfoiani2019@communityschoolnaples.org> | 2018-07-26 00:31:25 -0400 |
---|---|---|
committer | Michael Foiani <mfoiani2019@communityschoolnaples.org> | 2018-07-26 00:31:25 -0400 |
commit | f0815df6642642db3e5063b6800d2ed0f681754c (patch) | |
tree | 54fe65f3ddcffcc2c0524c64bf8e54a66c97779e /src/actions/firebase.js | |
parent | 2b253a35d7f33a256cf52d555ce5ca39206c7bb2 (diff) |
Created basic login system using firebase and redux.
Diffstat (limited to 'src/actions/firebase.js')
-rw-r--r-- | src/actions/firebase.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/actions/firebase.js b/src/actions/firebase.js new file mode 100644 index 0000000..e13ab10 --- /dev/null +++ b/src/actions/firebase.js @@ -0,0 +1,30 @@ +import { firebase } from '../firebase.js'; + +export const AUTH_FAIL = 'AUTH_FAIL'; +export const AUTH_SUCCESS = 'AUTH_SUCCESS'; + +const auth = firebase.auth(); + +export const signIn = (_email, _password) => (dispatch) => { + auth.signInWithEmailAndPassword(_email, _password).then((user) => { + dispatch(authSuccess(user.email)); + }) + .catch((error) => { + dispatch(authFail(error.code)); + }); + +} + +export const authFail = (errorCode) => { + return { + type: AUTH_FAIL, + payload: false + } +} + +export const authSuccess = (email) => { + return { + type: AUTH_SUCCESS, + payload: true + } +} |