Fix endpoint to check invitations

This commit is contained in:
Adolfo Reyna
2025-02-04 23:03:46 -05:00
parent b9a3768f4c
commit 62fcf4fe2c
2 changed files with 11 additions and 2 deletions

View File

@@ -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.

View File

@@ -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});