diff options
Diffstat (limited to 'src/actions/firebaseAuth.js')
-rw-r--r-- | src/actions/firebaseAuth.js | 83 |
1 files changed, 35 insertions, 48 deletions
diff --git a/src/actions/firebaseAuth.js b/src/actions/firebaseAuth.js index 9783d8a..c1bcd8a 100644 --- a/src/actions/firebaseAuth.js +++ b/src/actions/firebaseAuth.js @@ -48,27 +48,22 @@ export const signIn = (_email, _password, divison) => (dispatch) => { } -export const setUserData = (_divison) => (dispatch, getState) => { - const uid = getState().firebase.uid; - var docRef = firestore.collection('users').doc(uid); - docRef.set({ - hours: 0, - divison: _divison - }).catch((error) => { - console.log(error); - }) +export const signOut = () => (dispatch) => { + auth.signOut().then(() => { + dispatch(authSignOut()); + }); } -export const adminListener = () => (dispatch, getState) => { - document.onkeyup = function(e) { - if(e.altKey && e.which == 65) { - var docRef = firestore.collection('keys').doc('adminKey'); - docRef.get().then((doc) => { - if(prompt('Enter admin password') == doc.data().password) { - dispatch(adminControls()); - } - }); - } +export const authSignOut = () => { + return { + type: AUTH_SIGN_OUT, + payload: false, + code: "Signed Out User", + uid: "", + userEmail: "", + isAdmin: false, + requests: [], + compList: [] } } @@ -82,7 +77,7 @@ export const authFail = (errorCode) => { } export const authSuccess = (_user) => { - alert('Sign In Success'); + alert('Success. Checkout the other pages to see what you can do!'); return { type: AUTH_SUCCESS, payload: true, @@ -91,19 +86,30 @@ export const authSuccess = (_user) => { } } -export const fetchDivison = () => (dispatch, getState) => { +//End firebase auth + + +export const setUserData = (_divison) => (dispatch, getState) => { const uid = getState().firebase.uid; var docRef = firestore.collection('users').doc(uid); - - docRef.get().then((doc) => { - dispatch(updateDivison(doc.data().divison)); - }); + docRef.set({ + hours: 0, + divison: _divison + }).catch((error) => { + console.log(error); + }) } -export const updateDivison = (divison) => { - return { - type: UPDATE_DIVISON, - payload: divison +export const adminListener = () => (dispatch, getState) => { + document.onkeyup = function(e) { + if(e.altKey && e.which == 65) { + var docRef = firestore.collection('keys').doc('adminKey'); + docRef.get().then((doc) => { + if(prompt('Enter admin password') == doc.data().password) { + dispatch(adminControls()); + } + }); + } } } @@ -119,22 +125,3 @@ export const updateAdmin = () => { payload: true } } - -export const signOut = () => (dispatch) => { - auth.signOut().then(() => { - dispatch(authSignOut()); - }); -} - -export const authSignOut = () => { - return { - type: AUTH_SIGN_OUT, - payload: false, - code: "Signed Out User", - uid: "", - userEmail: "", - isAdmin: false, - requests: [], - compList: [] - } -} |