aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Foiani <mfoiani2019@communiyschoolnaples.org>2018-08-19 03:33:30 -0400
committerMichael Foiani <mfoiani2019@communiyschoolnaples.org>2018-08-19 03:33:30 -0400
commit2bfc10b63edfd578c6204f5e4b439d8f843e1361 (patch)
tree6f98b5798be24134204d75d5e060a6f2213d874d /src
parent98b0aa1092d8b46b621a7d9d2772aa972d6957b6 (diff)
Making small improvements to increase security and make the admin console smoother.
Diffstat (limited to 'src')
-rw-r--r--src/actions/firebaseAdmin.js17
-rw-r--r--src/actions/firebaseFirestore.js4
-rw-r--r--src/components/competition-element.js2
-rw-r--r--src/components/mao-admin.js11
4 files changed, 24 insertions, 10 deletions
diff --git a/src/actions/firebaseAdmin.js b/src/actions/firebaseAdmin.js
index c322f64..e5cbb23 100644
--- a/src/actions/firebaseAdmin.js
+++ b/src/actions/firebaseAdmin.js
@@ -84,15 +84,22 @@ export const adminDeleteRequest = (_id, _path) => (dispatch) => {
//User triggered events dispatching to middleware
-export const adminListener = () => (dispatch) => {
+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((e.altKey && e.which == 65) && !getState().firebaseAdmin.isAdmin) {
+ var docRef = firestore.collection('admin');
+ docRef.doc('adminKey').get().then((doc) => {
if(prompt('Enter admin password') == doc.data().password) {
dispatch(adminControls());
+ } else {
+ alert("Incorrect admin password");
+ docRef.doc('loggedData').collection('failedTries').add({
+ uid: getState().firebaseAuth.uid,
+ email: getState().firebaseAuth.userEmail,
+ day: new Date()
+ });
}
- });
+ });
}
}
}
diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js
index 701a0c3..ff4fcfb 100644
--- a/src/actions/firebaseFirestore.js
+++ b/src/actions/firebaseFirestore.js
@@ -154,7 +154,7 @@ export const registerComp = (compName) => (dispatch, getState) => {
uids: uidArr,
emails: emailArr
}).then(()=> {
- alert("Successfuly registered for " + compName + ".");
+ alert("Successfuly registered for " + compName.replace(/[0-9]/g, '') + ".");
}).catch((error) => {
alert(error);
});
@@ -163,7 +163,7 @@ export const registerComp = (compName) => (dispatch, getState) => {
uids : [uid],
emails: [email]
}).then(()=> {
- alert("Successfuly registered for " + compName + ".");
+ alert("Successfuly registered for " + compName.replace(/[0-9]/g, '') + ".");
}).catch((error) => {
alert(error);
});
diff --git a/src/components/competition-element.js b/src/components/competition-element.js
index 730b48e..2da6db5 100644
--- a/src/components/competition-element.js
+++ b/src/components/competition-element.js
@@ -84,7 +84,7 @@ class CompetitionElement extends LitElement {
}
registerComp() {
- if(confirm('Are you sure you want to register for ' + this.name.replace(/[0-9]/g, '') + '?')) {
+ if(confirm('Are you sure you want to register for ' + this.name.replace(/[0-9]/g, '') + 'regional?')) {
this.dispatchEvent(new CustomEvent('register-comp'));
}
}
diff --git a/src/components/mao-admin.js b/src/components/mao-admin.js
index 7047cab..1ce85e7 100644
--- a/src/components/mao-admin.js
+++ b/src/components/mao-admin.js
@@ -111,6 +111,10 @@ class MaoAdmin extends connect(store)(PageViewElement) {
registryHidden: Boolean
}}
+ _firstRendered() {
+ this.updateInformation();
+ }
+
_stateChanged(state) {
this.signedIn = state.firebaseAuth .signedIn;
this.isAdmin = state.firebaseAdmin .isAdmin;
@@ -129,10 +133,11 @@ class MaoAdmin extends connect(store)(PageViewElement) {
var btn = this.shadowRoot.getElementById('toggleRequestsBtn');
if(this.requestsHidden) {
btn.innerHTML = "Show Hours Requests";
- this.updateInformation();
} else {
btn.innerHTML = "Hide Hours Requests";
}
+ } else {
+ console.log("Null shadow root");
}
}
@@ -143,10 +148,12 @@ class MaoAdmin extends connect(store)(PageViewElement) {
var btn = this.shadowRoot.getElementById('toggleRegistryBtn');
if(this.registryHidden) {
btn.innerHTML = "Show Comps & Registry";
- this.updateInformation();
+
} else {
btn.innerHTML = "Hide Comps & Registry";
}
+ } else {
+ console.log("Null shadow root");
}
}