Skip to content

Commit

Permalink
fix(authentication-oauth): Allow hash based redirects (feathersjs#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Nov 11, 2019
1 parent 6b2e3e3 commit a50788e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 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 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 a50788e

Please sign in to comment.