Skip to content

Commit

Permalink
Add hooks and publishers to both services
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Jun 4, 2024
1 parent ebf3de1 commit 41d7aa9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/authentication-oauth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ export const oauth =
const serviceOptions = authenticationServiceOptions(authService, oauthOptions)
const servicePath = `${grantConfig.defaults.prefix || 'oauth'}/:provider`
const callbackServicePath = `${servicePath}/callback`
const oauthService = new OAuthService(authService, oauthOptions)

app.use(servicePath, new OAuthService(authService, oauthOptions), serviceOptions)

const oauthService = app.service(servicePath)

oauthService.hooks({
app.use(servicePath, oauthService, serviceOptions)
app.use(callbackServicePath, new OAuthCallbackService(oauthService), serviceOptions)
app.service(servicePath).hooks({
around: { all: [resolveDispatch(), redirectHook()] }
})
app.service(callbackServicePath).hooks({
around: { all: [resolveDispatch(), redirectHook()] }
})

app.use(
callbackServicePath,
new OAuthCallbackService(app.service(servicePath) as unknown as OAuthService),
serviceOptions
)

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

if (typeof app.service(callbackServicePath).publish === 'function') {
app.service(callbackServicePath).publish(() => null)
}
}

0 comments on commit 41d7aa9

Please sign in to comment.