从passportjs文档中,我可以重定向到URL
app.post('/login',
passport.authenticate('local', { successRedirect: '/',
failureRedirect: '/login' }));
假设successRedirect
应该是另一个不同的域
成功登录后,我的验证位于www.auth.com
中,我想使用来自www.customer.com/callback
的数据重定向到www.auth.com
。
实际上就像在成功将Facebook POST
数据登录到回调URL之后,使用回调URL进行Facebook身份验证
答案 0 :(得分:0)
app.get('/login', function(req, res) { //will handle if user fails to enter valid credentials
return res.render('login', {
message: 'Login Page Renderd...'
});
});
app.post('/login', passport.authenticate('local', {
successRedirect: '/profile', //will be redirected to `/profile` route after successful login
failureRedirect: '/login' //will be redirected to `/login` route for failure
}));
app.get('/profile', function(req, res) { //will handle if user enter valid credentials means user logged in successfully
return res.status(200).send('User Logged in successfully...');
});
Passport-Facebook,我们需要像Passport-Local一样为身份验证成功和失败定义回调URL。