Skip to content

Commit

Permalink
fix(authentication-oauth): Fix regression with prefix handling in OAu…
Browse files Browse the repository at this point in the history
…th (#2773)
  • Loading branch information
nsainaney authored Oct 6, 2022
1 parent ab580cb commit b1844b1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/authentication-oauth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { resolveDispatch } from '@feathersjs/schema'

import { OAuthStrategy, OAuthProfile } from './strategy'
import { redirectHook, OAuthService } from './service'
import { getServiceOptions, OauthSetupSettings } from './utils'
import { getGrantConfig, getServiceOptions, OauthSetupSettings } from './utils'

const debug = createDebug('@feathersjs/authentication-oauth')

Expand All @@ -30,17 +30,20 @@ export const oauth =
linkStrategy: 'jwt',
...settings
}

const grantConfig = getGrantConfig(authService)
const serviceOptions = getServiceOptions(authService, oauthOptions)
const servicePath = `${grantConfig.defaults.prefix || 'oauth'}/:provider`

app.use('oauth/:provider', new OAuthService(authService, oauthOptions), serviceOptions)
app.use(servicePath, new OAuthService(authService, oauthOptions), serviceOptions)

const oauthService = app.service('oauth/:provider')
const oauthService = app.service(servicePath)

oauthService.hooks({
around: { all: [resolveDispatch(), redirectHook()] }
})

if (typeof oauthService.publish === 'function') {
app.service('oauth/:provider').publish(() => null)
app.service(servicePath).publish(() => null)
}
}

0 comments on commit b1844b1

Please # to comment.