subscription chatMessageAdded security fix

This commit is contained in:
Ulf Gebhardt 2023-07-20 13:44:04 +02:00
parent 1b8b356432
commit f7c381efd8
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 5 additions and 8 deletions

View File

@ -25,8 +25,8 @@ export default {
chatMessageAdded: { chatMessageAdded: {
subscribe: withFilter( subscribe: withFilter(
() => pubsub.asyncIterator(CHAT_MESSAGE_ADDED), () => pubsub.asyncIterator(CHAT_MESSAGE_ADDED),
(payload, variables) => { (payload, variables, context) => {
return payload.userId === variables.userId return payload.userId === context.user?.id
}, },
), ),
}, },

View File

@ -46,5 +46,5 @@ type Query {
} }
type Subscription { type Subscription {
chatMessageAdded(userId: ID!): Message chatMessageAdded: Message
} }

View File

@ -195,9 +195,6 @@ export default {
// Subscriptions // Subscriptions
const observer = this.$apollo.subscribe({ const observer = this.$apollo.subscribe({
query: chatMessageAdded(), query: chatMessageAdded(),
variables: {
userId: this.currentUser.id,
},
}) })
observer.subscribe({ observer.subscribe({

View File

@ -54,8 +54,8 @@ export const messageQuery = () => {
export const chatMessageAdded = () => { export const chatMessageAdded = () => {
return gql` return gql`
subscription chatMessageAdded($userId: ID!) { subscription chatMessageAdded {
chatMessageAdded(userId: $userId) { chatMessageAdded {
_id _id
id id
indexId indexId