From 4909dda29566710793b8445ab4426102ca4a0324 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 22 Jun 2020 01:42:43 +0300 Subject: feat: create Votes service --- services/votes/votes.hooks.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 services/votes/votes.hooks.ts (limited to 'services/votes/votes.hooks.ts') diff --git a/services/votes/votes.hooks.ts b/services/votes/votes.hooks.ts new file mode 100644 index 0000000..2e29008 --- /dev/null +++ b/services/votes/votes.hooks.ts @@ -0,0 +1,15 @@ +import { + convertPollHook +} from '../../hooks/convertPoll'; + +import { authenticate } from '@feathersjs/authentication'; + +export default { + before: { + create: [authenticate('jwt')] + }, + after: { + all: [convertPollHook] + } +}; + -- cgit v1.2.3 From 676c722a994a214c182bcf26b80eab09ebf9f61e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 22 Jun 2020 21:29:17 +0300 Subject: refactor: unite convertPoll hooks --- services/votes/votes.hooks.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'services/votes/votes.hooks.ts') diff --git a/services/votes/votes.hooks.ts b/services/votes/votes.hooks.ts index 2e29008..a41b8a9 100644 --- a/services/votes/votes.hooks.ts +++ b/services/votes/votes.hooks.ts @@ -1,15 +1,12 @@ -import { - convertPollHook -} from '../../hooks/convertPoll'; - import { authenticate } from '@feathersjs/authentication'; +import convertPoll from '../../hooks/convertPoll'; export default { before: { create: [authenticate('jwt')] }, after: { - all: [convertPollHook] + all: [convertPoll] } }; -- cgit v1.2.3 From 681e51a658bfed723b368fc5b71b1350909d9496 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 11:02:54 +0300 Subject: feat: setup hooks for VoteService --- services/votes/votes.hooks.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'services/votes/votes.hooks.ts') diff --git a/services/votes/votes.hooks.ts b/services/votes/votes.hooks.ts index a41b8a9..63f19e3 100644 --- a/services/votes/votes.hooks.ts +++ b/services/votes/votes.hooks.ts @@ -1,12 +1,15 @@ +import { HookContext } from '@feathersjs/feathers'; import { authenticate } from '@feathersjs/authentication'; -import convertPoll from '../../hooks/convertPoll'; + +const addUserId = async (context: HookContext): Promise => { + const { params: { user} } = context; + context.data.userId = user._id; + return context; +}; export default { before: { - create: [authenticate('jwt')] - }, - after: { - all: [convertPoll] + create: [authenticate('jwt'), addUserId] } }; -- cgit v1.2.3 From 64f5f8c3f9660f649dfdaad07d84aa8c26b9661e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 12:08:15 +0300 Subject: feat: setup global auth hooks --- services/votes/votes.hooks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'services/votes/votes.hooks.ts') diff --git a/services/votes/votes.hooks.ts b/services/votes/votes.hooks.ts index 63f19e3..1cf7261 100644 --- a/services/votes/votes.hooks.ts +++ b/services/votes/votes.hooks.ts @@ -1,5 +1,5 @@ import { HookContext } from '@feathersjs/feathers'; -import { authenticate } from '@feathersjs/authentication'; +import requireAuth from '../../hooks/requireAuth'; const addUserId = async (context: HookContext): Promise => { const { params: { user} } = context; @@ -9,7 +9,7 @@ const addUserId = async (context: HookContext): Promise => { export default { before: { - create: [authenticate('jwt'), addUserId] + create: [requireAuth, addUserId] } }; -- cgit v1.2.3