0
我正在使用ExpressJS和PassportJS的Facebook策略來嘗試執行某些條件重定向對身份驗證回調,應在某些屬性丟失時調用。PassportJS和ExpressJS條件URL重定向
我的用戶模式:
var UserSchema = new Schema({
id: ObjectId,
uid: String,
facebookToken: String,
username: String,
password: String,
salt: String,
firstName: String,
lastName: String,
email: String,
birthday: Date,
gender: String,
location: String,
phone: Number,
verifiedPhone: Boolean,
interests: {
culture: Boolean,
food: Boolean,
business: Boolean,
family: Boolean,
learning: Boolean,
sports: Boolean,
movies: Boolean,
music: Boolean,
events: Boolean,
nightlife: Boolean,
health: Boolean,
beauty: Boolean,
fashion: Boolean,
motoring: Boolean,
electronics: Boolean,
groceries: Boolean,
travel: Boolean,
decor: Boolean
},
weeklyNotifcation: Number,
weeklyNotificationSent: Number,
created: {type: Date, default: Date.now}
});
我的回調:
app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login' }), function(req, res) {
User.findOne({uid: req.session.uid}, function(err, user) {
if(user.email || user.location || user.phone || user.location == undefined) {
res.redirect('/register');
} else {
res.redirect('/');
}
});
});
的數據被存儲到蒙戈/auth/facebook
被調用後。我檢查數據庫使用會話,並檢查它是否未定義,因爲它們不存儲在數據庫中,因爲它不會返回字段。回調失敗並且沒有收到任何數據。
任何幫助將不勝感激。
你是否設法解決這個問題?我也有同樣的問題 –