From 3eefdf61063f50c5666ed761710fa3b1b669c011 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sat, 22 Feb 2014 20:53:21 +0200 Subject: [PATCH] Check "data.query" exists Check "data.query" exists before checking the data.query.session_id. Avoid: "TypeError: Cannot read property 'session_id' of undefined " --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index fa363c3..fba65e1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -35,7 +35,7 @@ function authorize(options) { return function(data, accept){ data.cookie = parseCookie(auth, data.headers.cookie || ''); - data.sessionID = data.query.session_id || data.cookie[auth.key] || ''; + data.sessionID = (data.query && data.query.session_id) || data.cookie[auth.key] || ''; data[auth.userProperty] = { logged_in: false };