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
Post a Comment