UNPKG

527 BPlain TextView Raw
1import { HookContext, NextFunction } from '@feathersjs/feathers'
2import { createDebug } from '@feathersjs/commons'
3import { ConnectionEvent } from '../core'
4
5const debug = createDebug('@feathersjs/authentication/hooks/connection')
6
7export 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}