aboutsummaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorMichael Foiani <mfoiani2019@communityschoolnaples.org>2018-09-15 21:43:51 +0000
committerMichael Foiani <mfoiani2019@communityschoolnaples.org>2018-09-15 21:43:51 +0000
commit5afa931ec2d48ed6aefafcb122b63be435e734ed (patch)
tree6054754d879d12ad6ffa996ca7ee478ba877ae91 /src/actions
parent0d6ea57b2b58111110f3a578b8ac7a14772d809b (diff)
Revert "Created basic fix for new accounts to update username info when creatiing account."
This reverts commit 0d6ea57b2b58111110f3a578b8ac7a14772d809b
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/firebaseAuth.js8
-rw-r--r--src/actions/firebaseFirestore.js12
2 files changed, 8 insertions, 12 deletions
diff --git a/src/actions/firebaseAuth.js b/src/actions/firebaseAuth.js
index 8f12c73..37f6643 100644
--- a/src/actions/firebaseAuth.js
+++ b/src/actions/firebaseAuth.js
@@ -38,7 +38,7 @@ export const authSignOut = () => {
export const createAccount = (_email, _password, divison) => (dispatch) => {
auth.createUserWithEmailAndPassword(_email, _password).then(() => {
- dispatch(setUserData(_email, _password, divison));
+ dispatch(signIn(_email, _password, divison));
})
.catch((error) => {
alert(error.code + ": " + error.message);
@@ -53,11 +53,10 @@ import {
import {
adminListener,
- adminClose,
- updateUserInfo
+ adminClose
} from './firebaseAdmin.js'
-export const signIn = (_email, _password) => (dispatch) => {
+export const signIn = (_email, _password, divison) => (dispatch) => {
auth.signInWithEmailAndPassword(_email, _password).then(() => {
var user = auth.currentUser;
/* User is signed in.
@@ -70,6 +69,7 @@ export const signIn = (_email, _password) => (dispatch) => {
var providerData = user.providerData;
*/
dispatch(authSuccess(user));
+ if(divison) { dispatch(setUserData(divison)); }
dispatch(fetchDivison());
dispatch(snapshotHours())
dispatch(snapshotRegisteredCompetitions());
diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js
index 4234f4a..49e79c7 100644
--- a/src/actions/firebaseFirestore.js
+++ b/src/actions/firebaseFirestore.js
@@ -94,19 +94,15 @@ export const snapshotForums = () => (dispatch) => {
//Do not dipatch to store, only update firebaseFirestore
-export const setUserData = (_email, _password,_divison) => (dispatch, getState) => {
+export const setUserData = (_divison) => (dispatch, getState) => {
const uid = getState().firebaseAuth.uid;
var docRef = firestore.collection('users').doc(uid);
docRef.set({
hours: 0,
- divison: _divison,
- username: _email.replace('@communityschoolnaples.org', '')
- }).then(() => {
- dispatch(signIn(_email, _password));
- })
- .catch((error) => {
+ divison: _divison
+ }).catch((error) => {
console.log(error);
- });
+ })
}
export const requestHours = (_time, _trainee, _location, _subject, _date, _pictureName) => (dispatch, getState) => {