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 15 16 17 18 19 20 | 1x 1x 1x 10x 10x 8x 7x 1x | import { BadRequest } from '@feathersjs/errors'; import { checkContext } from 'feathers-hooks-common'; import type { HookContext } from '@feathersjs/feathers'; /** * Throws if `context.params?.user?.isVerified` is not true */ export default function isVerified (): ((context: HookContext) => HookContext) { return (context: HookContext): HookContext => { checkContext(context, 'before'); if (!context.params?.user?.isVerified) { throw new BadRequest('User\'s email is not yet verified.'); } return context; }; } |