paulvanbladel / aurelia-auth

:key: Authentication plugin for aurelia
200 stars 74 forks source link

getMe() not working with Facebook #151

Closed LeoNero closed 8 years ago

LeoNero commented 8 years ago

Hi! I'm creating an Aurelia project that contains facebook login. My code is similar to https://github.com/paulvanbladel/aurelia-auth-sample .

My files are: authUtils.js: https://gist.github.com/LeoNero/68a8188f4dbbf24dea8143255ed07a4c

routes/api.js

'use strict'

const apiController = require('../controllers/api.js');
const authUtils = require('../config/authUtils.js');

module.exports = app => {
  app.get('/me', authUtils.ensureAuthenticated, apiController.getMe);
};

controllers/api.js

'use strict'

const User = require('../models/user.js');

const ApiController = {
  getMe(req, res) {
    User.findById(req.user, function (err, user) {
      if (!user) {
        return res.status(404).send({message: 'User not found'});
      }

      res.send(user);
    });
  }
};

module.exports = ApiController;

However, when I go to 'localhost/me' to look what the server has returned, I always get the following message: {"message":"Please make sure your request has an Authorization header"}

How can I fix it?