1602 / compound-passport Goto Github PK
View Code? Open in Web Editor NEWPassportJS integrated with Compound
PassportJS integrated with Compound
You lost three return done(err, user) in the local.js:
exports.callback = function (email, password, done) {
.....................................
var len = exports.User.verifyPassword.length;
if (len === 2) {
if (!exports.User.verifyPassword(password, user.encrypt_password)) {
"return" done(err, false);
} else {
"return" done(err, user);
}
} else if (len === 3) {
exports.User.verifyPassword(password, user.password, function(err, isMatch) {
"return" done(err, !err && isMatch ? user : false);
});
}
return done(err, false);
});
};
Hi Anatoliy! I'm using compound-passport but I don't know how it works with the local strategy?
I realized that, for some reason, your code breaks HTTP PUT, so you will receive a "Undefined action" when updating a Model:
Loading railway-passport before:
// init passport
rwps.init();
// hook up user model
process.nextTick(function () {
rwpass.loadUser(User);
});
app.use(app.router);
You should load railway-passport after loading the routes.
app.use(app.router);
// init passport
rwps.init();
// hook up user model
process.nextTick(function () {
rwpass.loadUser(User);
});
Nice job btw, I like your railway framework.
I ran into an issue when writing my local authentication with bcrypt.
strategies/local.js expects the following:
if (!exports.User.verifyPassword(password, user.password)) {
However, User.verifyPassword
is always defined..
I propose to change the local.js strategy to the following.
exports.User.verifyPassword(password, user.password, function(err, isMatch) {
if(err) {
console.log("Error!");
throw err;
}
else {
if(isMatch) {
done(err,user);
}
else {
done(err,false);
}
}
});
});
That way verifyPassword can execute asynchronously and return user/false along with errors.
Your verifyPassword method in your users model would look like this:
User.verifyPassword = function (password, hash, callback) {
bcrypt.compare(password, hash, function(err, isMatch){
callback(err, isMatch);
});
}
I'd be happy to submit a pull request for this. Unless anyone knows of a better way to accomplish this.
When using verifyPassword with callback i get
Error: Can't set headers after they are sent.
You need to add else statement to last call to done
return done(err, !err && isMatch ? user : false);
});
} else {
return done(err, false);
}
There is 0.0.9 version in master branch, but latest release is 0.0.8.
After creating a new railwayjs install in Win32, running railway generate crud post title content
, I add this line to my environment.js (no other changes):
var rwps = require('railway-passport');
Then I attempt to start the server and get this error:
C:\node\test\railway-passport>railway server
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
For reference, here is the config/environment.js file:
var express = require('express');
var rwps = require('railway-passport');
app.configure(function(){
var cwd = process.cwd();
app.use(express.static(cwd + '/public', {maxAge: 86400000}));
app.set('views', cwd + '/app/views');
app.set('view engine', 'ejs');
app.set('view options', {complexNames: true});
app.set('jsDirectory', '/javascripts/');
app.set('cssDirectory', '/stylesheets/');
app.use(express.bodyParser());
app.use(express.cookieParser('secret'));
app.use(express.session({secret: 'secret'}));
app.use(express.methodOverride());
//init passport
// rwps.init();
// // hook up user model
// process.nextTick(function () {
// rwps.loadUser(User);
// });
app.use(app.router);
});
And here is my version data:
C:\Documents and Settings\a93453\My Documents\workspaces\tests\auth>node -v
v0.6.13
C:\Documents and Settings\a93453\My Documents\workspaces\tests\auth>npm ls
npm WARN [email protected] package.json: bugs['name'] should probably be bugs['url']
[email protected] C:\Documents and Settings\a93453\My Documents\workspaces\tests\auth
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected] extraneous
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Error: Not Found
at ServerResponse.error (/home/node/npm-www/node_modules/error-page/error-page.js:108:20)
at MC.ondone (/home/node/npm-www/routes/package-page.js:31:53)
at MC.next (/home/node/npm-www/node_modules/emcee/emcee.js:45:12)
at AsyncCache.get (/home/node/npm-www/node_modules/async-cache/ac.js:58:7)
at Array.forEach (native)
at AsyncCache.get (/home/node/npm-www/node_modules/async-cache/ac.js:57:9)
at CouchLogin. (/home/node/npm-www/models/downloads.js:108:12)
at CouchLogin. (/home/node/npm-www/node_modules/couch-login/couch-login.js:161:15)
at Request.init.self.callback (/home/node/npm-www/node_modules/request/index.js:148:22)
at Request.EventEmitter.emit (events.js:99:17)
Getting this error on /callback... using facebook strategy
TypeError: Cannot call method 'findOrCreate' of undefined
at Strategy.exports.callback as _verify
Also what would be the simplest way to override say /strategies/facebook.js or more precisely the callback to be used on facebook.js strategy
Please help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.