How to implement the widgets with the data in express?

For example, the time menu, if the person is authorized then he is shown the link to your account, and if not, then login / registration. To transfer all calls to res.render() isAuthorize variable(true|false) I think is not an option. I would like to pass it to something like the widget to only that logic was. Use express+jade
June 27th 19 at 15:23
1 answer
June 27th 19 at 15:25
Solution
The first time you open/refresh the page supersuite session information. And store it for example in localStorage. About the validation on the server. If the passport you will use it in the body of the req adds the validation method of the session, if in manual, write model var to check session on each request.

Res. render() isAuthorize variable(true|false)


This will not happen if the req stage, you will learn that the user is not authorized

app.get('/someUrl', isAuthorize, someController);
isAuthorize function(req, res, next){
// check user session
if(false) return res.send("you should login")
next();
}

Find more questions by tags Express.jsPugJavaScriptNode.js