Skip to content

Commit

Permalink
fix(authentication-oauth): Update OAuth redirect to handle user reque…
Browse files Browse the repository at this point in the history
…sted redirect paths (#3186)
  • Loading branch information
engineertdog committed May 5, 2023
1 parent 42bd5e4 commit 3742028
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/authentication-oauth/src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {
}

const redirectUrl = `${redirect}${queryRedirect}`
const separator = redirect.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#'
const separator = redirectUrl.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#'
const authResult: AuthenticationResult = data
const query = authResult.accessToken
? { access_token: authResult.accessToken }
Expand Down
8 changes: 8 additions & 0 deletions packages/authentication-oauth/test/strategy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ describe('@feathersjs/authentication-oauth/strategy', () => {
)
assert.strictEqual('/home/hi-there#access_token=testing', redirect)

redirect = await strategy.getRedirect(
{ accessToken: 'testing' },
{
redirect: '/hi-there?'
}
)
assert.equal(redirect, '/home/hi-there?access_token=testing')

redirect = await strategy.getRedirect(new Error('something went wrong'))
assert.equal(redirect, '/home#error=something%20went%20wrong')

Expand Down

0 comments on commit 3742028

Please sign in to comment.