All files / src/helpers hash-password.ts

85.71% Statements 6/7
50% Branches 1/2
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 151x     1x 146x 146x           146x 146x    
import { hooks as authLocalHooks } from '@feathersjs/authentication-local';
import { Application, HookContext } from '@feathersjs/feathers';
 
export default async function hashPassword (app: Application, password: string, field: string): Promise<string> {
  Iif (!field) throw new Error('Field is missing');
  const context = {
    type: 'before',
    data: { [field]: password },
    params: { provider: null },
    app
  };
  const newContext = await authLocalHooks.hashPassword(field)(context as HookContext);
  return newContext.data[field];
}