From 0f3ad00086ffcabe3b8bfac8b4a169ffe0d49416 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Sun, 28 Jul 2013 10:11:29 -0700 Subject: [PATCH] Remove auth middleware and passport until adding in acl and strategies --- README.md | 32 -------------------------------- lib/middleware/auth.js | 34 ---------------------------------- test/user.test.js | 2 -- 3 files changed, 68 deletions(-) delete mode 100644 lib/middleware/auth.js diff --git a/README.md b/README.md index 51982f91..72273445 100644 --- a/README.md +++ b/README.md @@ -976,38 +976,6 @@ Create a user like any other model. 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 diff --git a/lib/middleware/auth.js b/lib/middleware/auth.js deleted file mode 100644 index c278aa8c..00000000 --- a/lib/middleware/auth.js +++ /dev/null @@ -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); - } -} - - diff --git a/test/user.test.js b/test/user.test.js index 3a6f6f8b..127a7f5f 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -17,8 +17,6 @@ describe('User', function(){ User.setMaxListeners(22); beforeEach(function (done) { - app.use(loopback.cookieParser()); - app.use(loopback.auth()); app.use(loopback.rest()); app.model(User);