mirror of https://gitgud.io/fatchan/jschan.git
merge-requests/208/head
parent
38b8c1f7e2
commit
e7b4a60e95
13 changed files with 93 additions and 85 deletions
@ -1,16 +1,18 @@ |
||||
'use strict'; |
||||
|
||||
module.exports = (req, res) => { |
||||
return req.session.authenticated //if the user is authed
|
||||
&& req.session.user //if the user is logged in
|
||||
&& ( |
||||
req.session.user.authLevel > 1 //and is not a regular user
|
||||
|| ( |
||||
res.locals.board |
||||
&& ( |
||||
res.locals.board.owner == req.session.user.username //and board owner
|
||||
|| res.locals.board.moderators.includes(req.session.user.username) //or board mod
|
||||
) |
||||
) |
||||
) |
||||
const { authenticated, user } = req.session; |
||||
if (authenticated === true && user != null) { |
||||
if (user.authLevel <= 1) { |
||||
return user.authLevel; //admin 0, global staff, 1
|
||||
} |
||||
if (res.locals.board != null) { |
||||
if (res.locals.board.owner === user.username) { |
||||
return 2; //board owner 2
|
||||
} else if (res.locals.board.moderators.includes(user.username) === true) { |
||||
return 3; //board staff 3
|
||||
} |
||||
} |
||||
} |
||||
return 4; //not logged in/too low level for anything atm
|
||||
} |
||||
|
Loading…
Reference in new issue