mongodb
This commit is contained in:
parent
1e373c1986
commit
c7e355e81f
1 changed files with 9 additions and 6 deletions
|
@ -6,16 +6,19 @@ async function auth (req, res, next) {
|
|||
const user = req.session.user;
|
||||
const isAuth = req.session.isAuthenticated;
|
||||
|
||||
if (!user || !isAuth) {
|
||||
return next();
|
||||
}
|
||||
|
||||
const userDoc = await db.getDb().collection('users').findOne({_id: user.id})
|
||||
|
||||
if (userDoc && userDoc.isAdmin) {
|
||||
|
||||
const isAdmin = userDoc.isAdmin;
|
||||
const isAdmin = userDoc.isAdmin;
|
||||
|
||||
res.locals.user = userDoc;
|
||||
res.locals.isAuth = isAuth;
|
||||
res.locals.isAdmin = isAdmin;
|
||||
|
||||
res.locals.user = userDoc;
|
||||
res.locals.isAuth = isAuth;
|
||||
res.locals.isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue