Fix endpoint to check invitations
This commit is contained in:
9
index.js
9
index.js
@@ -110,6 +110,15 @@ DB.getDB.then((DB) => {
|
|||||||
DB.setWebSubscription(profileid, subscription);
|
DB.setWebSubscription(profileid, subscription);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/invite/:email", async (req, res) => {
|
||||||
|
const email = req.params.email;
|
||||||
|
//validate email?
|
||||||
|
if(!email) return res.json({status: "provide valid email"});
|
||||||
|
let r = await DB.getInvitation(email);
|
||||||
|
if(!r) return res.json({status: "no invitation found with that email"});
|
||||||
|
return res.json({status: "ok", ... r});
|
||||||
|
});
|
||||||
|
|
||||||
// Function to Singup new users. An user is a combination of a user obj and a profile.
|
// Function to Singup new users. An user is a combination of a user obj and a profile.
|
||||||
// When new users are subscribed, they have a single profile, which is the personal one.
|
// When new users are subscribed, they have a single profile, which is the personal one.
|
||||||
// Other profiles can be link to that user, like groups or courses.
|
// Other profiles can be link to that user, like groups or courses.
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ DB.getDB.then((DB)=>{
|
|||||||
|
|
||||||
router.get("/invite/:email", async (req, res) => {
|
router.get("/invite/:email", async (req, res) => {
|
||||||
const userid = getUserId(req);
|
const userid = getUserId(req);
|
||||||
const email = req.body.email;
|
const email = req.params.email;
|
||||||
//validate email?
|
//validate email?
|
||||||
if(email) return res.json({status: "provide valid email"});
|
if(!email) return res.json({status: "provide valid email"});
|
||||||
let r = await DB.getInvitation(email);
|
let r = await DB.getInvitation(email);
|
||||||
if(!r) return res.json({status: "no invitation found with that email"});
|
if(!r) return res.json({status: "no invitation found with that email"});
|
||||||
return res.json({status: "ok", ... r});
|
return res.json({status: "ok", ... r});
|
||||||
|
|||||||
Reference in New Issue
Block a user