aboutsummaryrefslogtreecommitdiff
path: root/src/actions/firebaseAdmin.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions/firebaseAdmin.js')
-rw-r--r--src/actions/firebaseAdmin.js17
1 files changed, 12 insertions, 5 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()
+ });
}
- });
+ });
}
}
}