aboutsummaryrefslogtreecommitdiff
path: root/hooks/requireAuth.ts
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 21:25:18 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 21:25:18 +0300
commitfd484a217c77dba42c29fae1cfdb2390422da847 (patch)
treeb11c527bbc0a268f0361a4d56f6aff7011960f98 /hooks/requireAuth.ts
parent050d3e087b3ce2c9dd892a96daf215402292aa2c (diff)
downloadwhich-api-fd484a217c77dba42c29fae1cfdb2390422da847.tar.gz
feat: add logger and handle eveyrthing nicely
Diffstat (limited to 'hooks/requireAuth.ts')
-rw-r--r--hooks/requireAuth.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/hooks/requireAuth.ts b/hooks/requireAuth.ts
index a7b0e96..52e8974 100644
--- a/hooks/requireAuth.ts
+++ b/hooks/requireAuth.ts
@@ -1,7 +1,10 @@
+import { NotAuthenticated } from '@feathersjs/errors';
import { HookContext } from '@feathersjs/feathers';
export default async (context: HookContext): Promise<HookContext> => {
- if (!context.params.user) throw new Error('This endpoint requires auth!');
+ if (!context.params.authenticated) {
+ throw new NotAuthenticated('This endpoint requires auth!');
+ }
return context;
};