SpartanConnect / restful-api-backend

node.js & Express RESTful API
1 stars 0 forks source link

Authentication #10

Closed nrlysek closed 7 years ago

nrlysek commented 7 years ago

We need authentication for many of our API endpoints. We will probably use OAuth(2) and Google's API's.

encadyma commented 7 years ago

The middleware for this has been implemented in feature/auth (96e42bf331757720af13a7984720e2cddef9bbb0).

You can protect your routes by importing utilities/auth.js and adding the .verifyAuthenticated function to your route like so:

var auth = require('../utilities/auth');
...
router.get('/users/me', auth.verifyAuthenticated(), (req, res) => {
    // implementation here.
});