File tree Expand file tree Collapse file tree 2 files changed +10
-22
lines changed Expand file tree Collapse file tree 2 files changed +10
-22
lines changed Original file line number Diff line number Diff line change @@ -5,23 +5,21 @@ module.exports = (strategy = 'jwt') => {
5
5
const {
6
6
method,
7
7
result : { accessToken } ,
8
- params : { provider , connection }
8
+ params : { connection }
9
9
} = context ;
10
10
11
- if ( ! connection && ( provider === 'socketio' || provider === 'primus' ) ) {
12
- throw new Error ( `No connection object found. Please make sure you are using the latest version of '@feathersjs/ ${ provider } ' and params.connection is set.` ) ;
11
+ if ( ! connection ) {
12
+ return context ;
13
13
}
14
14
15
- if ( connection ) {
16
- const { authentication : { accessToken : currentToken } = { } } = connection ;
15
+ const { authentication = { } } = connection ;
17
16
18
- if ( method === 'remove' && accessToken === currentToken ) {
19
- debug ( 'Removing authentication information from real-time connection' ) ;
20
- delete connection . authentication ;
21
- } else if ( method === 'create' && accessToken ) {
22
- debug ( 'Adding authentication information to real-time connection' ) ;
23
- connection . authentication = { strategy, accessToken } ;
24
- }
17
+ if ( method === 'remove' && accessToken === authentication . accessToken ) {
18
+ debug ( 'Removing authentication information from real-time connection' ) ;
19
+ delete connection . authentication ;
20
+ } else if ( method === 'create' && accessToken ) {
21
+ debug ( 'Adding authentication information to real-time connection' ) ;
22
+ connection . authentication = { strategy, accessToken } ;
25
23
}
26
24
27
25
return context ;
Original file line number Diff line number Diff line change @@ -29,16 +29,6 @@ describe('authentication/hooks/connection', () => {
29
29
} ) ;
30
30
} ) ;
31
31
32
- it ( 'throws error if connection is not set for expected provider' , ( ) => {
33
- return service . create ( { } , { provider : 'socketio' } )
34
- . then ( ( ) => assert . fail ( 'Should never get here' ) )
35
- . catch ( error => {
36
- assert . strictEqual ( error . message , `No connection object found. ` +
37
- `Please make sure you are using the latest version of '@feathersjs/socketio' ` +
38
- `and params.connection is set.` ) ;
39
- } ) ;
40
- } ) ;
41
-
42
32
it ( 'create does nothing when there is no connection' , ( ) => {
43
33
return service . create ( { } , { } ) . then ( result => {
44
34
assert . deepStrictEqual ( result , {
You can’t perform that action at this time.
0 commit comments