Hello guys,
I am just getting started using everyauth and I could need some help:
I would like to have the following ways to login:
1) using (google, facebook, twitter)
2) or username password based
3) using (google, fb, ...) or pw
(1) and (2) alone are not a problem, thx at this place, this is pretty well implemented, love it :)
but (3) is a nasty thing, in detail I would like to have the following use case:
I also want to combine (1) and (2), so if a user logs in using his google account I want him allways redirect to the registration form so that he can define a username and a password. So that he can login next time using his username and password.
So, and now to my questions:
1) if the user logs in the first time (using google, fb,..) than I don't want to have him to be logged in, but, everyauth always thinks he is logged in (everyauth.loggedIn = true), how can I prevent it doing that?
2) how do I pass data from the google login to my registration form, so that I can pre-fill some fields?
I was trying following approach:
@everyauth
.google
#unnecessary data removed
.findOrCreateUser (sess, accessToken, extra, googleUser, data) ->
#unnecessary data removed
if user_not_exists
sess.user_exists = false
else
return user # user is null if user does not exists
.sendResponse (res, data) =>
user_exists = data.session.user_exists
if (! user_exists)
return res.redirect('/register')
res.redirect('/')
@everyauth
.password
#unnecessary data removed
.extractExtraRegistrationParams (req) ->
return {
email: req.body.email
google_id: req.body.google_id
facebook_id: req.body.facebook_id
twitter_id: req.body.twitter_id
}
.displayRegister (req, res, data) ->
userParams = {}
############## extract google data ###########
user = req.session.auth.google.user
userParams.email = user.email
res.render('register', { userParams: userParams })
.registerUser (newUserAttrs) ->
console.log newUserAttrs # google_id is not available anymore
since the user is logged in after logging in using his google account, I have access to req.session.auth.google.XXX and can send them to the form, but in the next step "registerUser(newUserAttrs) the google_id is gone, ( I assume it's because I don't have a field for that in my jade file), but I really would need it,
because I don't want the user to be logged in after logging in via google (that sentence sounds wrong to me :) ) I don't think that my approach is right, so I wondered if you would have a better idea.
cheers, bonomat
sorry for the bad formating, doesn't google provide some kind of code highlighting?