aboutsummaryrefslogtreecommitdiff
path: root/hooks/tryAuthenticate.ts
blob: aa9764846a0a5d01b05fba1abd51fb44cfa69ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { HookContext } from '@feathersjs/feathers';
import { authenticate } from '@feathersjs/authentication';


export default async (context: HookContext): Promise<HookContext> => {
  const authorization = context.params?.headers?.authorization;
  if (authorization && authorization !== 'null' && context.path !== 'authentication') {
    return authenticate('jwt')(context);
  }
  return context;
};