I'm working on a node express app, and I've got it working well with the Facebook authentication already. I'm now attempting to enable our own email/password login and running it to a roadblock. With Facebook I am able to access and write to the session during auth:
everyauth.faceboook
// Basic stuff
.findOrCreateUser( function( sess, accessToken, extra, fbUser) {
var promise = this.Promise();
sess.myvar = myvar
// Find user in DB, etc
promise.fulfill(fbUser);
return promise()
This works great as I can save some stuff I need later to the session right in this method. But I'm not sure how to do the same thing when using everyauth password login:
everyauth.password
// Basic stuff
.authenticate( function(email, password) {
var promise = this.Promise();
// Create new user in DB, etc
// Now I need to save stuff to the session but I'm not sure how to access
// it in here...
promise.fulfill(newUser)
return promise
So is there any way to access the session in the authenticate and login methods (which use the same API) of everyauth.password?
You can't access the session from your .authenticate
function, and what you're trying to do here feels wrong. Your .authenticate
function should simply be looking up the user by the login
parameter, validating that the password
parameter matches the user's password and then returning the user object for that user via the callback. If you want to use everyauth to also create users you should be using the .validateRegistration
and .registerUser
functions.