i am creating an application with angularjs and nodejs.
how to authenticate and authorize user in angularjs. say for example before sending a template to the user i have to check whether the user has access to it or not.
And also is it possible to send some request to server instead of angular?
for eg if the user hits www.example.com/sample#/template1, then he will be shown with template1 with the help of angular routing,
$routeProvider.
when('/', {templateUrl: '/template1', controller: ctrl1}).
otherwise({redirectTo: '/invalid'});
instead of this that particular req has to be handled by node server.
app.get(/sample/template1)
// do the following
Thanks in advance
Your question isn't too clear, but here are some directions you may want to investigate.
The '/' route in your current setup will provide your base Angular app with a template from /template1. This is the url that you need to support from a node perspective to serve up that html file. In your sample route, the user isn't going to be directed to /template1, but /invalid because the URL you are using(www.example.com/sample#/template1) is an Angular URL. If you want the user to go to /template1 from an Angular perspective, they need to just go to www.example.com/sample/.
On the node.js side, you need to use some type of middleware for authentication if you are using express.js, otherwise you would roll your own before returning the html file. Just don't put the partial html files in a static folder (if express.js) because the middleware checks will be bypassed.