From 6f07a6e80c77d90a72bb5344a1f867dbd854976b Mon Sep 17 00:00:00 2001 From: Derek McKenna Date: Wed, 10 Jan 2018 10:32:57 +1100 Subject: [PATCH] fix getcookie cookie fallbacks for signed vs unsigned --- index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 3c2a5df9..cdaa7828 100644 --- a/index.js +++ b/index.js @@ -536,16 +536,7 @@ function getcookie(req, name, secrets) { // back-compat read from cookieParser() signedCookies data if (!val && req.signedCookies) { - val = req.signedCookies[name]; - - if (val) { - deprecate('cookie should be available in req.headers.cookie'); - } - } - - // back-compat read from cookieParser() cookies data - if (!val && req.cookies) { - raw = req.cookies[name]; + raw = req.signedCookies[name]; if (raw) { if (raw.substr(0, 2) === 's:') { @@ -565,6 +556,15 @@ function getcookie(req, name, secrets) { } } + // back-compat read from cookieParser() cookies data + if (!val && req.cookies) { + val = req.cookies[name]; + + if (val) { + deprecate('cookie should be available in req.headers.cookie'); + } + } + return val; }