angularjs - Middleware between passport and angular -


first off, i'm new this. i'm writing sails application angular front end , using passport authentication. access session data front end after user has logged in. i've read multiple places data in user object in api/policies/passport.js can accessed in controller-served view, have no idea go inside controller. have far standard code inside api/policies/passport.js, assets/js/controllers.js, , assets/partials/partial1.html. don't have code show here. can show me example of this?

follow tutorial implement passport.js authentication: https://www.bearfruit.org/2014/07/21/tutorial-easy-authentication-for-sails-js-apps/

after you've done can access season data in homepage this:

<html>       welcom back:       <% if(typeof user.username != 'undefined'){ user.username }%> </html> 

in server side can access data this:

index: function(req, res) {     res.json(req.user); } 

attach controller view:

in sails/views folder create new file called authhp.ejs. in sails/controllers create new controller called authhpcontroller.js code:

module.exports = {      index: function( req,res ){         console.log("if see request made authhp.ejs , controller");         res.view('authhp');     }  }; 

now go config/routes , add this:

'/authhp': { controller: 'authhpcontroller' }

now should working


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -