How to get the equivalent of "req.something" from angular with nodejs

I follow the guide on setting authentication using nodejs and passport. ( http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local )

The tutorial presents rendering templates with ejs and transferring flash data.

Instead, I would like to use angularjs. I'm having trouble getting flash data. I know how to use templates and send variables, but what does angular replace "req.flash (" signupMessage ") in the code below?

This is the code that the tutorial shows:

app.get('/signup', function(req, res) { // render the page and pass in any flash data if it exists res.render('signup.ejs', { message: req.flash('signupMessage') }); }); 

This is the code in which I configured my route

 // public/js/appRoutes.js angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider // show signup form .when('/signup', { templateUrl: 'views/signup.html', controller: 'SignupController' }); $locationProvider.html5Mode(true); }]); 

Here is the controller:

  // public/js/controllers/SetupCtrl.js angular.module('SignupCtrl', []).controller('SignupController', function($scope) { $scope.tagline = 'TEST'; }); 
+5
source share
1 answer

This question was answered: What is the correct way to log in using Angular and Express?

TL; DR: the answer was sent to the following link, where the author describes that you need to save all the passport materials on the server side, and then allow the client side (angular stuff) to request information about the session, http://vickev.com/#! / article / authentication-in-single-page-applications-node-js-passportjs-angularjs

+1
source

Source: https://habr.com/ru/post/1200983/


All Articles