From de001e139ec0ff7c51a5df75d73b32f4670c1371 Mon Sep 17 00:00:00 2001 From: Fazil Vadakkumpadath Date: Tue, 27 Nov 2018 13:16:42 +0100 Subject: [PATCH 1/3] Added path and method in to express request for passport --- packages/authentication/lib/hooks/authenticate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/authentication/lib/hooks/authenticate.js b/packages/authentication/lib/hooks/authenticate.js index e147252679..bcb2cabae8 100644 --- a/packages/authentication/lib/hooks/authenticate.js +++ b/packages/authentication/lib/hooks/authenticate.js @@ -47,6 +47,8 @@ module.exports = function authenticate (_strategies, options = {}) { query: hook.data, body: hook.data, params: hook.params, + path: hook.path, + method: hook.method, headers: hook.params.headers || {}, cookies: hook.params.cookies || {}, session: {} From 350c5f6c36fdbfcdc6c770564287ecf581fbdf78 Mon Sep 17 00:00:00 2001 From: Fazil Vadakkumpadath Date: Thu, 29 Nov 2018 13:30:41 +0100 Subject: [PATCH 2/3] Fixed unit tests after adding path and method in to express request for passport --- packages/authentication/test/hooks/authenticate.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/authentication/test/hooks/authenticate.test.js b/packages/authentication/test/hooks/authenticate.test.js index 73e22fca5b..0a6a7201ff 100644 --- a/packages/authentication/test/hooks/authenticate.test.js +++ b/packages/authentication/test/hooks/authenticate.test.js @@ -33,7 +33,9 @@ describe('hooks:authenticate', () => { cookies: { 'feathers-jwt': 'token' } - } + }, + path: 'test', + method: 'POST' }; }); @@ -91,6 +93,8 @@ describe('hooks:authenticate', () => { query: hook.data, body: hook.data, params: hook.params, + path: hook.path, + method: hook.method, headers: hook.params.headers, cookies: hook.params.cookies, session: {} From 40fe9e311006cc92fa4680d0ca0de3150bde2f08 Mon Sep 17 00:00:00 2001 From: Fazil Vadakkumpadath Date: Fri, 30 Nov 2018 09:45:14 +0100 Subject: [PATCH 3/3] Added normalization from feathers method to express method --- packages/authentication/lib/hooks/authenticate.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/authentication/lib/hooks/authenticate.js b/packages/authentication/lib/hooks/authenticate.js index bcb2cabae8..d67b18b310 100644 --- a/packages/authentication/lib/hooks/authenticate.js +++ b/packages/authentication/lib/hooks/authenticate.js @@ -43,12 +43,21 @@ module.exports = function authenticate (_strategies, options = {}) { // NOTE (EK): Passport expects an express/connect // like request object. So we need to create one. + const methodMap = { + find: 'GET', + get: 'GET', + create: 'POST', + update: 'PUT', + patch: 'PATCH', + remove: 'DELETE' + }; + let request = { query: hook.data, body: hook.data, params: hook.params, path: hook.path, - method: hook.method, + method: methodMap[hook.method] || hook.method, headers: hook.params.headers || {}, cookies: hook.params.cookies || {}, session: {}