Answer the question
In order to leave comments, you need to log in
How to make a redirect after authorization in NODE?
Greetings, dear, tell me how to redirect to a specific page after successful authorization, having this code:
app.post("/login", function(req, res, next) {
return login(req, res, next);
});
return login = function(req, res, next) {
return passport.authenticate("local", function(err, user, info) {
if (err) {
return JsonRenderer.error(err, res, 401);
}
if (!user) {
return JsonRenderer.error("Invalid credentials", res, 401);
}
return req.logIn(user, function(err) {
if (err) {
return JsonRenderer.error("Invalid credentials", res, 401);
}
return UserToken.findByUserAndType(user.id, "google_auth", function(err, googleToken) {
if (googleToken && !googleToken.isValidGAuthPass(req.body.gauth_pass)) {
req.logout();
return JsonRenderer.error("Invalid Google Authenticator code", res, 401);
}
res.json(JsonRenderer.user(req.user));
return AuthStats.log({
ip: req.ip,
user: req.user
}, req.user.email_auth_enabled && !req.user.recenltySignedUp());
});
});
})(req, res, next);
};
Answer the question
In order to leave comments, you need to log in
well, where in your code (did not find) successful authorization, do a redirectres.redirect(301, 'http://example.com');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question