1 | import { HookContext, NextFunction } from '@feathersjs/feathers'
|
2 | import { createDebug } from '@feathersjs/commons'
|
3 | import { ConnectionEvent } from '../core'
|
4 |
|
5 | const debug = createDebug('@feathersjs/authentication/hooks/connection')
|
6 |
|
7 | export default (event: ConnectionEvent) => async (context: HookContext, next: NextFunction) => {
|
8 | await next()
|
9 |
|
10 | const { app, result, params } = context
|
11 |
|
12 | if (params.provider && result) {
|
13 | debug(`Sending authentication event '${event}'`)
|
14 | app.emit(event, result, params, context)
|
15 | }
|
16 | }
|