Skip to content

Commit

Permalink
fix: Added path and method in to express request for passport (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
fazilvp authored and daffl committed Dec 16, 2018
1 parent 9f1200f commit afa1cb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/authentication/lib/hooks/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
6 changes: 5 additions & 1 deletion packages/authentication/test/hooks/authenticate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ describe('hooks:authenticate', () => {
cookies: {
'feathers-jwt': 'token'
}
}
},
path: 'test',
method: 'POST'
};
});

Expand Down Expand Up @@ -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: {}
Expand Down

0 comments on commit afa1cb4

Please sign in to comment.