Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { authenticate } = require('@feathersjs/authentication').hooks;
const emotionRatingHook = require('./hooks/emotion-rating');
const { isVerified } = require('feathers-authentication-management').hooks;
const hooks = require('feathers-hooks-common');
module.exports = {
before: {
all: [authenticate('jwt')],
find: [],
get: [],
create: [
hooks.when(hooks.isProvider('external'),
isVerified()
)],
update: [hooks.disallow()],
patch: [hooks.disallow()],
remove: [hooks.disallow('external')]
},
after: {
all: [
// populate({ schema: userSchema }),
// populate({ schema: contributionSchema })
],
find: [],
get: [],
create: [emotionRatingHook()],
update: [],
patch: [],
childField: '_id',
query: {
$select: ['_id', 'name', 'slug', 'avatar', 'createdAt', 'lastActiveAt']
}
}
};
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
associateCurrentUser()
)
// mapCreateToUpsert(context => {
// const { data } = context;
// return { userId: data.userId, foreignId: data.foreignId, foreignService: data.foreignService };
// })
],
update: [
authenticate('jwt'),
unless(isModerator(),
restrictToOwner()
)
],
patch: [
authenticate('jwt'),
unless(isModerator(),
authenticate('jwt'),
// Allow seeder to seed contributions
associateCurrentUser(),
unless(isProvider('server'),
isVerified(),
canEditOrganization()
),
associateCurrentUser(),
createSlug({field: 'title'}),
saveRemoteImages(['teaserImg']),
createExcerpt()
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
canEditOrganization()
),
unless(isModerator(),
excludeDisabled(),
restrictToOwner()
),
saveRemoteImages(['teaserImg']),
createExcerpt(),
setNow('updatedAt')
],
patch: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
canEditOrganization()
),
hook => {
delete hook.params.query.deleted;
return hook;
}
],
get: [
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
)
],
create: [
authenticate('jwt'),
// Allow seeder to seed comments
unless(isProvider('server'),
isVerified()
),
associateCurrentUser(),
createExcerpt({ length: 180 })
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
restrictToOwner()
),
createExcerpt({ length: 180 }),
setNow('updatedAt')
],
patch: [
authenticate('jwt'),
unless(isProvider('server'),
const {
associateCurrentUser,
restrictToOwner
} = require('feathers-authentication-hooks');
const { isVerified } = require('feathers-authentication-management').hooks;
const setDoneDate = require('./hooks/set-done-date');
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [
unless(isProvider('server'),
authenticate('jwt'),
isVerified(),
associateCurrentUser()
),
setDoneDate()
],
update: [
authenticate('jwt'),
unless(isModerator(),
restrictToOwner()
),
setDoneDate()
],
patch: [
authenticate('jwt'),
unless(isModerator(),
restrictToOwner()
),
const { unless, isProvider } = require('feathers-hooks-common');
const { isVerified } = require('feathers-authentication-management').hooks;
const { authenticate } = require('@feathersjs/authentication').hooks;
const isAdmin = require('../../hooks/is-admin');
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
isAdmin()
)
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
isAdmin()
)
],
patch: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
isAdmin()
)
const setShoutCount = require('./hooks/set-shout-count');
const {
associateCurrentUser,
restrictToOwner
} = require('feathers-authentication-hooks');
const { isVerified } = require('feathers-authentication-management').hooks;
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
associateCurrentUser()
)
],
update: [
authenticate('jwt'),
unless(isModerator(),
restrictToOwner()
)
],
patch: [
authenticate('jwt'),
unless(isModerator(),
restrictToOwner()
)
],
remove: [
.replace(/<[a-z]>[\s]*<\/[a-z]>/igm, '')
.replace(/<p>[\s]*(<br>)+[\s]*<\/p>/igm, '<br>')
.replace(/(<br>){2,}/igm, '<br>')
.replace(/[\n]{3,}/igm, '\n\n');
};
};
module.exports = {
before: {
all: [],
find: [],
get: [],
create: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
isAdmin()
),
createSlug({ field: 'key', unique: false }),
cleanupHTML()
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
isAdmin()
),
cleanupHTML()
],
patch: [
authenticate('jwt'),
unless(isProvider('server'),</p>
),
when(isModerator(),
hook => {
hook.data.reviewedBy = hook.params.user.userId;
return hook;
}
),
associateCurrentUser(),
createSlug({ field: 'name' }),
createExcerpt({ field: 'description' }),
saveRemoteImages(['logo', 'coverImg'])
],
update: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified()
),
stashBefore(),
restrictReviewAndEnableChange(),
restrictToOwnerOrModerator({ isEnabled: true }),
createSlug({ field: 'name', overwrite: true }),
createExcerpt({ field: 'description' }),
saveRemoteImages(['logo', 'coverImg'])
],
patch: [
authenticate('jwt'),
unless(isProvider('server'),
isVerified()
),
stashBefore(),
restrictReviewAndEnableChange(),
restrictToOwnerOrModerator({ isEnabled: true }),