2013-07-02 23:51:38 +00:00
|
|
|
/**
|
|
|
|
* Module dependencies.
|
|
|
|
*/
|
|
|
|
|
2013-07-16 17:49:25 +00:00
|
|
|
var loopback = require('../loopback')
|
2013-07-02 23:51:38 +00:00
|
|
|
, passport = require('passport');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Export the middleware.
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = auth;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build a temp app for mounting resources.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function auth() {
|
|
|
|
return function (req, res, next) {
|
2013-07-16 17:49:25 +00:00
|
|
|
var sub = loopback();
|
2013-07-02 23:51:38 +00:00
|
|
|
|
|
|
|
// TODO clean this up
|
|
|
|
sub._models = req.app._models;
|
|
|
|
sub._remotes = req.app._remotes;
|
|
|
|
|
2013-07-16 17:49:25 +00:00
|
|
|
sub.use(loopback.session({secret: 'change me'}))
|
2013-07-02 23:51:38 +00:00
|
|
|
sub.use(passport.initialize());
|
|
|
|
sub.use(passport.session());
|
|
|
|
|
|
|
|
sub.handle(req, res, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|