Invitation only for signup
This commit is contained in:
@@ -14,6 +14,8 @@ DB.getDB.then((DB)=>{
|
||||
router.get("/", async (req, res) => {
|
||||
const profileid = getProfileId(req);
|
||||
let posts = await DB.getFeed(profileid);
|
||||
//Add non-organic posts
|
||||
|
||||
return res.json(posts)
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/new", async (req, res) => {
|
||||
router.get("/new", async (req, res) => { //Deprecated please use route post("/")
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
... req.query.content
|
||||
@@ -37,6 +37,47 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
... req.body.content
|
||||
};
|
||||
let profileObj = new Profile(profile);
|
||||
let r = await DB.newProfile(profileObj);
|
||||
return res.json({
|
||||
status: "ok",
|
||||
... profileObj.toObj()
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/invite", async (req, res) => {
|
||||
const userid = getUserId(req);
|
||||
const name = req.body.name;
|
||||
const email = req.body.email;
|
||||
//validate email?
|
||||
if(!name || !email) return res.json({status: "incomplete request"});
|
||||
let r = await DB.newInvitation(userid, name, email);
|
||||
if(!r.toLowerCase){
|
||||
//send email invitation
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
}
|
||||
return res.json({
|
||||
status: r
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/invite/:email", async (req, res) => {
|
||||
const userid = getUserId(req);
|
||||
const email = req.body.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});
|
||||
});
|
||||
|
||||
router.get("/groups", async (req, res) => {
|
||||
let groups = await DB.getGroups();
|
||||
return res.json({
|
||||
|
||||
Reference in New Issue
Block a user