Delete profiles and posts

This commit is contained in:
aeroreyna
2022-02-16 20:33:20 -08:00
parent 294cacf963
commit 117bc5833a
5 changed files with 63 additions and 2 deletions

View File

@@ -48,10 +48,15 @@ DB.getDB.then((DB)=>{
const sessionChecker = async (req, res, next) => {
const session_id = getSessionId(req);
const user_sid = getUserId(req);
const profile_id = getProfileId(req);
let profile_id = getProfileId(req);
if (session_id && user_sid) {
const userInfo = await DB.checkSessionOnDB(session_id, user_sid);
req.userInfo = userInfo;
if(!await DB.getProfileCache(profile_id)){
const latestProfile = await DB.latestProfile(user_sid);
res.cookie('profile_id', latestProfile._id, cookiesOptions);
profile_id = latestProfile._id;
}
req.profileInfo = {_id: profile_id}
if(!userInfo) return res.redirect('/login');
next();