Remove auth middleware and passport until adding in acl and strategies

This commit is contained in:
Ritchie Martori 2013-07-28 10:11:29 -07:00
parent 89f65d792f
commit 0f3ad00086
3 changed files with 0 additions and 68 deletions

View File

@ -976,38 +976,6 @@ Create a user like any other model.
console.log(user); console.log(user);
}); });
#### Authentication Strategies (Using Passport.js)
Setup an authentication strategy.
[See all available providers from passport.js](http://passportjs.org/guide/providers/).
// first add your model to your app
app.model(User);
// by default your User model has a local strategy similar to below
// customize your own
// disable the default local strategy
User.useLocalStrategy(false);
// create a custom strategy
var LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy(function(username, password, done) {
User.findOne({ username: username }, function(err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false, { message: 'Unknown user ' + username }); }
user.comparePassword(password, function(err, isMatch) {
if (err) return done(err);
if(isMatch) {
return done(null, user);
} else {
return done(null, false, { message: 'Invalid password' });
}
});
});
}));
#### Login a User #### Login a User

View File

@ -1,34 +0,0 @@
/**
* Module dependencies.
*/
var loopback = require('../loopback')
, passport = require('passport');
/**
* Export the middleware.
*/
module.exports = auth;
/**
* Build a temp app for mounting resources.
*/
function auth() {
return function (req, res, next) {
var sub = loopback();
// TODO clean this up
sub._models = req.app._models;
sub._remotes = req.app._remotes;
sub.use(loopback.session({secret: 'change me'}))
sub.use(passport.initialize());
sub.use(passport.session());
sub.handle(req, res, next);
}
}

View File

@ -17,8 +17,6 @@ describe('User', function(){
User.setMaxListeners(22); User.setMaxListeners(22);
beforeEach(function (done) { beforeEach(function (done) {
app.use(loopback.cookieParser());
app.use(loopback.auth());
app.use(loopback.rest()); app.use(loopback.rest());
app.model(User); app.model(User);