wildflock/hooks/validate-auth.ts

9 lines
324 B
TypeScript

import { NotAuthenticated } from '@feathersjs/errors'
import type { HookContext, NextFunction } from '../declarations'
// Check if user is stored in session
export const validateAuth = async (context: HookContext) => {
if (!context.params.session?.user) {
throw new NotAuthenticated('Not authenticated')
}
}