Skip to content

Commit

Permalink
fix(authentication-oauth): Allow hash based redirects (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Nov 11, 2019
1 parent e1939be commit ffe7cf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/authentication-oauth/src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {
return null;
}

const separator = redirect.endsWith('?') ? '' : '#';
const separator = redirect.endsWith('?') ? '' :
(redirect.indexOf('#') !== -1 ? '?' : '#');
const authResult: AuthenticationResult = data;
const query = authResult.accessToken ? {
access_token: authResult.accessToken
Expand Down
5 changes: 5 additions & 0 deletions packages/authentication-oauth/test/strategy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ describe('@feathersjs/authentication-oauth/strategy', () => {

redirect = await strategy.getRedirect({ accessToken: 'testing' });
assert.equal(redirect, null);

app.get('authentication').oauth.redirect = '/#dashboard';

redirect = await strategy.getRedirect({ accessToken: 'testing' });
assert.equal(redirect, '/#dashboard?access_token=testing');
});

it('getProfile', async () => {
Expand Down

0 comments on commit ffe7cf3

Please sign in to comment.