Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

[WIP] Fix 404 on removing a comment #182

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions server/services/comments/comments.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const xssFields = ['content', 'contentExcerpt'];
module.exports = {
before: {
all: [
softDelete(),
xss({ fields: xssFields })
],
find: [
softDelete(),
// We want to deleted comments to show up
iff(
hook => hook.params.headers && hook.params.headers.authorization,
Expand All @@ -52,12 +52,14 @@ module.exports = {
}
],
get: [
softDelete(),
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
)
],
create: [
softDelete(),
authenticate('jwt'),
// Allow seeder to seed comments
unless(isProvider('server'),
Expand All @@ -67,6 +69,7 @@ module.exports = {
createExcerpt({ length: 180 })
],
update: [
softDelete(),
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
Expand All @@ -76,6 +79,7 @@ module.exports = {
setNow('updatedAt')
],
patch: [
softDelete(),
authenticate('jwt'),
unless(isProvider('server'),
isVerified(),
Expand All @@ -101,11 +105,18 @@ module.exports = {
})
],
remove: [
authenticate('jwt'),
unless(isProvider('server'),
unless(isModerator(),
iff(isProvider('server'),
softDelete(),
authenticate('jwt')
).else( // isProvider == false
iff(isModerator(),
softDelete(),
authenticate('jwt')
).else( // isModerator == false
authenticate('jwt'),
isVerified(),
restrictToOwner()
restrictToOwner(),
softDelete()
)
)
]
Expand Down