Fix improper null check

This commit is contained in:
calzoneman 2015-02-20 23:23:10 -06:00
parent 9ab4e02a5d
commit a6eaa944c1
1 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@ function handleLogin(req, res) {
var password = req.body.password; var password = req.body.password;
var rememberMe = req.body.remember; var rememberMe = req.body.remember;
var dest = req.body.dest || req.header("referer") || null; var dest = req.body.dest || req.header("referer") || null;
dest = dest.match(/login|logout/) ? null : dest; dest = dest && dest.match(/login|logout/) ? null : dest;
if (typeof name !== "string" || typeof password !== "string") { if (typeof name !== "string" || typeof password !== "string") {
res.sendStatus(400); res.sendStatus(400);
@ -122,7 +122,7 @@ function handleLogout(req, res) {
res.clearCookie("auth"); res.clearCookie("auth");
// Try to find an appropriate redirect // Try to find an appropriate redirect
var dest = req.query.dest || req.header("referer"); var dest = req.query.dest || req.header("referer");
dest = dest.match(/login|logout|account/) ? null : dest; dest = dest && dest.match(/login|logout|account/) ? null : dest;
var host = req.hostname; var host = req.hostname;
if (host.indexOf(Config.get("http.root-domain")) !== -1) { if (host.indexOf(Config.get("http.root-domain")) !== -1) {