node.js - How to authenticate/authorize express routes in loopback -


i've created loopback app , extended user model user authentication/authorization.

i'm trying check if user logged in or not express route redirect user /login if user not logged in.

so far seems loopback authenticates/authorizes exposed model methods /user/update. i'm not able find on how loopback authenticate/authorize express routes i've defined.

thanks in advance

here's thing, i'm not @ loopback know little expressjs.

in express, if wanna auth, can use middleware of own , use before other routes handle request.

you might want consider express-session login status storage.

when log in :

route.post('/login',function(req,res,next){     //login here     req.session.user = user }) 

and own middleware:

function auth(req,res,next){   if(!req.session.user){      res.redirect('/login')   } } 

https://github.com/expressjs/session


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -