Delete profiles and posts
This commit is contained in:
7
index.js
7
index.js
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user