v1.7.4/release

- create party tests
This commit is contained in:
2020-09-10 19:13:48 -04:00
parent e1e28ec638
commit bd4b824a45
+13
View File
@@ -1,11 +1,24 @@
const admin = require('firebase-admin'); const admin = require('firebase-admin');
const partyNameHasInvalidChar = (partyName) =>
/\\/gi.test(partyName) || /\//gi.test(partyName) || /\./gi.test(partyName);
const isValidPin = (pin) => /^.*[0-9].{2}$/.test(pin);
module.exports = async (req, res) => { module.exports = async (req, res) => {
const bodydata = JSON.parse(req.body); const bodydata = JSON.parse(req.body);
console.log('Requested Create - UID - ', bodydata.uid); console.log('Requested Create - UID - ', bodydata.uid);
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' }); if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' });
if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' }); if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' });
if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' }); if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' });
if (partyNameHasInvalidChar(bodydata.partyName)) {
res.status(400).send({ message: 'Party name can not have "\\" or "/" or "."' });
}
if (!isValidPin(bodydata.partyPin)) {
res
.status(400)
.send({ message: 'Party pin can only have digits and must be atleast 3 digits' });
}
const roomNameTaken = await admin const roomNameTaken = await admin
.firestore() .firestore()
.collection('rooms') .collection('rooms')