From d5e324978cbdadfeef6b1fa10b7a24cc4891cb5d Mon Sep 17 00:00:00 2001 From: Xeovalyte Date: Thu, 22 Sep 2022 16:39:11 +0200 Subject: [PATCH] added userdata --- backend/index.js | 32 ++++++++++++- frontend/app.vue | 37 ++++++++++++--- frontend/components/Login.vue | 45 +++++++++++++++++-- .../settings/config/managerelatiecodes.vue | 12 +++++ 4 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 frontend/pages/settings/config/managerelatiecodes.vue diff --git a/backend/index.js b/backend/index.js index f9c6219..dfb7c94 100644 --- a/backend/index.js +++ b/backend/index.js @@ -2,6 +2,7 @@ const express = require('express'); const cors = require('cors'); const { initializeApp, applicationDefault, cert } = require('firebase-admin/app'); const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore'); +const { verifyIdToken } = require('firebase-admin/auth') const serviceAccount = require('./firebase.json'); @@ -48,6 +49,35 @@ app.post('/checkrelatiecode', async (req, res) => { } catch (e) { - return res.status(500).send({ error: e }) + return res.status(500).send({ code: 'error', error: e }) + } +}) + +app.post('/getrelatiecodes', async (req, res) => { + const { email } = req.body; + + if (!email) return res.status(400).send({ code: 'no-email'}) + + try { + const ledenlijstRef = db.collection('ledenlijst') + + const snapshot = await ledenlijstRef.where("email", "array-contains", email).get() + + if (snapshot.empty) { + res.status(400).send({ code: 'no-relatiecodes'}) + return; + } + + let relatiecodes = []; + + snapshot.forEach(doc => { + relatiecodes.push(doc.id) + }); + + res.status(200).send({ code: 'success', relatiecodes: relatiecodes }) + + + } catch (e) { + return res.status(500).send({ code: 'error', error: e }) } }) \ No newline at end of file diff --git a/frontend/app.vue b/frontend/app.vue index 0841c99..39a64d2 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -17,7 +17,7 @@ \ No newline at end of file diff --git a/frontend/components/Login.vue b/frontend/components/Login.vue index 28769d5..6ae9818 100644 --- a/frontend/components/Login.vue +++ b/frontend/components/Login.vue @@ -43,8 +43,10 @@ \ No newline at end of file