I have used node.js restify and angularjs to create a web app with no user administration. Now, I would like to add the user administration feature.

Users need to login to gain access to the web app. If they are not authenticated, they will be redirected to a default URL at www.webroot.com/login.html.

I am looking at the right node.js module to implement this feature but am at a loss at the moment. The 2 modules that caught my attention is passport-restify and passport-http.

https://www.npmjs.com/package/passport-restify https://www.npmjs.com/package/passport-http

Here are some questions to implement this feature;

  • Which node.js module can be used to implement this user login feature? What is the difference between the two?

  • Is the actual URL redirecting action done using angularjs or node.js?

What are some sample code examples for user login? So far, I find documentation but few sample codes.

share|improve this question
    
did you try passport.js? – Yaakov Dec 19 '15 at 9:26
    
@Yaakov, no, I did not. Getting confused. Isn't that similar to passport-restify and passport-http? – user781486 Dec 19 '15 at 9:27
    
Use the middlewares.. it will helps you i think – Nalla Srinivas Dec 19 '15 at 9:34
    
"What are some sample code examples for user login?" Really..? You have 1k rep... you should know what is on topic and what is not in the site by now... – T J Dec 19 '15 at 9:44
up vote 1 down vote accepted

This module restify-ensure-login meets your requirements very well. https://www.npmjs.com/package/restify-ensure-login

This middleware ensures that a user is logged in. If a request is received that is unauthenticated, the request will be redirected to a login page. The URL will be saved in the session, so the user can be conveniently returned to the page that was originally requested.

Since your existing code base is in restify and this module makes use of restify, it is less of a hassle than to make use of most of the examples out there which use Express.

share|improve this answer

In order to provide a authentication system to the application u need to protect the api server side and also the views i have used this sample

https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens

please check this might be usefull

share|improve this answer
    
I am using restify currently. Are there examples using restify instead of express? – user781486 Dec 19 '15 at 12:07
    
no i have tried with express sorry – DhanaLaxshmi Dec 19 '15 at 12:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.