diff --git a/packages/authentication/lib/hooks/authenticate.js b/packages/authentication/lib/hooks/authenticate.js index e147252679..d67b18b310 100644 --- a/packages/authentication/lib/hooks/authenticate.js +++ b/packages/authentication/lib/hooks/authenticate.js @@ -43,10 +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: methodMap[hook.method] || hook.method, headers: hook.params.headers || {}, cookies: hook.params.cookies || {}, session: {} 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: {}