UNPKG

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