Skip to content

Commit 3742028

Browse files
authored
fix(authentication-oauth): Update OAuth redirect to handle user requested redirect paths (#3186)
1 parent 42bd5e4 commit 3742028

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/authentication-oauth/src/strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {
9696
}
9797

9898
const redirectUrl = `${redirect}${queryRedirect}`
99-
const separator = redirect.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#'
99+
const separator = redirectUrl.endsWith('?') ? '' : redirect.indexOf('#') !== -1 ? '?' : '#'
100100
const authResult: AuthenticationResult = data
101101
const query = authResult.accessToken
102102
? { access_token: authResult.accessToken }

packages/authentication-oauth/test/strategy.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ describe('@feathersjs/authentication-oauth/strategy', () => {
4343
)
4444
assert.strictEqual('/home/hi-there#access_token=testing', redirect)
4545

46+
redirect = await strategy.getRedirect(
47+
{ accessToken: 'testing' },
48+
{
49+
redirect: '/hi-there?'
50+
}
51+
)
52+
assert.equal(redirect, '/home/hi-there?access_token=testing')
53+
4654
redirect = await strategy.getRedirect(new Error('something went wrong'))
4755
assert.equal(redirect, '/home#error=something%20went%20wrong')
4856

0 commit comments

Comments
 (0)