Skip to content

Commit

Permalink
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/authentication-oauth/src/express.ts
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ export default (options: OauthSetupSettings) => {
const service = app.defaultAuthentication(authService);
const [ strategy ] = service.getStrategies(name) as OAuthStrategy[];
const params = {
...req.feathers,
authStrategies: [ name ],
authentication: accessToken ? {
strategy: linkStrategy,
1 change: 1 addition & 0 deletions packages/authentication-oauth/test/express.test.ts
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ describe('@feathersjs/authentication-oauth/express', () => {

assert.ok(data.accessToken);
assert.equal(data.user.testId, 'expressTest');
assert.equal(data.fromMiddleware, 'testing');
});

it('oauth/test/authenticate with redirect', async () => {
17 changes: 16 additions & 1 deletion packages/authentication-oauth/test/fixture.ts
Original file line number Diff line number Diff line change
@@ -11,9 +11,20 @@ export class TestOAuthStrategy extends OAuthStrategy {
if (!data.id) {
throw new Error('Data needs an id');
}

return data;
}

async authenticate (data: AuthenticationRequest, params: Params) {
const { fromMiddleware } = params;
const authResult = await super.authenticate(data, params);

if (fromMiddleware) {
authResult.fromMiddleware = fromMiddleware;
}

return authResult;
}
}

const port = 3000;
@@ -46,6 +57,10 @@ app.set('authentication', {
}
});

app.use((req, _res, next) => {
req.feathers = { fromMiddleware: 'testing' };
next();
});
app.use('/authentication', auth);
app.use('/users', memory());

0 comments on commit 854c9ca

Please sign in to comment.