Skip to content

Commit afa1cb4

Browse files
fazilvpdaffl
authored andcommitted
fix: Added path and method in to express request for passport (#1112)
1 parent 9f1200f commit afa1cb4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/authentication/lib/hooks/authenticate.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,21 @@ module.exports = function authenticate (_strategies, options = {}) {
4343

4444
// NOTE (EK): Passport expects an express/connect
4545
// like request object. So we need to create one.
46+
const methodMap = {
47+
find: 'GET',
48+
get: 'GET',
49+
create: 'POST',
50+
update: 'PUT',
51+
patch: 'PATCH',
52+
remove: 'DELETE'
53+
};
54+
4655
let request = {
4756
query: hook.data,
4857
body: hook.data,
4958
params: hook.params,
59+
path: hook.path,
60+
method: methodMap[hook.method] || hook.method,
5061
headers: hook.params.headers || {},
5162
cookies: hook.params.cookies || {},
5263
session: {}

packages/authentication/test/hooks/authenticate.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ describe('hooks:authenticate', () => {
3333
cookies: {
3434
'feathers-jwt': 'token'
3535
}
36-
}
36+
},
37+
path: 'test',
38+
method: 'POST'
3739
};
3840
});
3941

@@ -91,6 +93,8 @@ describe('hooks:authenticate', () => {
9193
query: hook.data,
9294
body: hook.data,
9395
params: hook.params,
96+
path: hook.path,
97+
method: hook.method,
9498
headers: hook.params.headers,
9599
cookies: hook.params.cookies,
96100
session: {}

0 commit comments

Comments
 (0)