users and profiles working
This commit is contained in:
13
index.js
13
index.js
@@ -140,6 +140,19 @@ DB.getDB.then((DB)=>{
|
||||
return await login(req, res);
|
||||
});
|
||||
|
||||
app.post('/changeProfile', sessionChecker, async (req, res) => {
|
||||
const user_sid = getUserId(req);
|
||||
let profile = await DB.getProfile(req.body.profileid);
|
||||
if(!profile || profile.userid != user_sid) return res.json({
|
||||
status: "profile does not belong to the logged user",
|
||||
});
|
||||
res.cookie('profile_id', profile._id, cookiesOptions);
|
||||
return res.json({
|
||||
status: "ok",
|
||||
...profile
|
||||
});
|
||||
});
|
||||
|
||||
// route for user logout
|
||||
const logout = function(req, res){
|
||||
const session_id = getSessionId(req);
|
||||
|
||||
Reference in New Issue
Block a user