| It is more convenient for us to use Google and Facebook login mechanisms than to create one from the scratch. We use two methods provided by Passportjs (plus.login and userinfo.email). I guess one of these asks for age range. You can check their documentation for more details at http://www.passportjs.org/docs/google/. And for the transparency sake, these are the parts of code on our side. router.get('/callback',
passportGoogle.authenticate('google', {
failureRedirect: '/'
}),
(req, res, next) => {
let user = req.user.doc;
let userId = user.userid; ///
res.cookie('token', userId, { ...
and this is what is saved to Mongo DB:var UserSchema = new mongoose.Schema({
name: String,
userid: String,
email: String,
sourcePlatform: String,
updated_at: { type: Date, default: Date.now },
}); Hope that helps ;) |
It looks like the age range is a component of the plus.login scope. You’re not storing any data associated with that scope, so you can instead use the userinfo.email scope (and, possibly, the userinfo.profile scope) to ask for only the information you need.