diff --git a/packages/authentication/src/hooks/authenticate.ts b/packages/authentication/src/hooks/authenticate.ts index 0f68f2e25d..21650cbc07 100644 --- a/packages/authentication/src/hooks/authenticate.ts +++ b/packages/authentication/src/hooks/authenticate.ts @@ -55,7 +55,7 @@ export default (originalSettings: string|AuthenticateHookSettings, ...originalSt const authResult = await authService.authenticate(authentication, authParams, ...strategies); - context.params = merge({}, params, omit(authResult, 'accessToken')); + context.params = merge({}, params, omit(authResult, 'accessToken'), { authenticated: true }); return context; } else if (!authentication && provider) { diff --git a/packages/authentication/test/fixtures.ts b/packages/authentication/test/fixtures.ts index 8908eface5..40c1991f1e 100644 --- a/packages/authentication/test/fixtures.ts +++ b/packages/authentication/test/fixtures.ts @@ -15,7 +15,8 @@ export class Strategy1 extends AuthenticationBaseStrategy { user: { id: 123, name: 'Dave' - } + }, + authenticated: true }; async authenticate (authentication: AuthenticationRequest) { @@ -40,7 +41,8 @@ export class Strategy2 extends AuthenticationBaseStrategy { user: { name: 'V2', version: 2 - } + }, + authenticated: true }; authenticate (authentication: AuthenticationRequest, params: Params) { diff --git a/packages/authentication/test/jwt.test.ts b/packages/authentication/test/jwt.test.ts index 569f0b920d..2e2c6b052e 100644 --- a/packages/authentication/test/jwt.test.ts +++ b/packages/authentication/test/jwt.test.ts @@ -162,13 +162,14 @@ describe('authentication/jwt', () => { const result = await app.service('protected').get('test', params); - assert.strictEqual(Object.keys(result.params).length, 3); + assert.strictEqual(Object.keys(result.params).length, 4); assert.ok(!result.params.accessToken, 'Did not merge accessToken'); assert.deepStrictEqual(result, { id: 'test', params: merge({}, params, { user, - authentication: { payload } + authentication: { payload }, + authenticated: true }) }); }); @@ -186,12 +187,13 @@ describe('authentication/jwt', () => { const result = await app.service('protected').get('test', params); - assert.strictEqual(Object.keys(result.params).length, 2); + assert.strictEqual(Object.keys(result.params).length, 3); assert.ok(!result.params.accessToken, 'Did not merge accessToken'); assert.deepStrictEqual(result, { id: 'test', params: merge({}, params, { - authentication: { payload } + authentication: { payload }, + authenticated: true }) }); });