From dfd30cbaacdc6dc880773531afb967300c18dc00 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Fri, 13 Dec 2019 10:17:19 +0100 Subject: [PATCH] Remove check for setting name to null or undefined - this was making things more likely to fail from the frontend, we would need to consider doing a db manipulation for users from the old alpha who have user.name as null. - it only protects against someone who bypasses our UI and sends a message directly to the backend, but if they can do that we have bigger problems. --- backend/src/middleware/validation/validationMiddleware.js | 5 ++--- webapp/components/Embed/EmbedComponent.vue | 1 - webapp/components/LocaleSwitch/LocaleSwitch.vue | 1 - webapp/components/Upload/index.vue | 1 - webapp/pages/settings/embeds.vue | 1 - webapp/pages/settings/privacy.vue | 1 - webapp/pages/terms-and-conditions-confirm.vue | 1 - 7 files changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/src/middleware/validation/validationMiddleware.js b/backend/src/middleware/validation/validationMiddleware.js index 8caf73e0c..948e1a73a 100644 --- a/backend/src/middleware/validation/validationMiddleware.js +++ b/backend/src/middleware/validation/validationMiddleware.js @@ -129,10 +129,9 @@ export const validateNotifyUsers = async (label, reason) => { const validateUpdateUser = async (resolve, root, params, context, info) => { const { name } = params - if (typeof name === 'string' && name.trim().length > USERNAME_MIN_LENGTH) - return resolve(root, params, context, info) - if (typeof name !== 'string' || name.trim().length < USERNAME_MIN_LENGTH) + if (typeof name === 'string' && name.trim().length < USERNAME_MIN_LENGTH) throw new UserInputError(`Username must be at least ${USERNAME_MIN_LENGTH} character long!`) + return resolve(root, params, context, info) } export default { diff --git a/webapp/components/Embed/EmbedComponent.vue b/webapp/components/Embed/EmbedComponent.vue index 0ce33682c..f1790304e 100644 --- a/webapp/components/Embed/EmbedComponent.vue +++ b/webapp/components/Embed/EmbedComponent.vue @@ -132,7 +132,6 @@ export default { mutation: updateUserMutation(), variables: { id: this.currentUser.id, - name: this.currentUser.name, allowEmbedIframes, }, update: (store, { data: { UpdateUser } }) => { diff --git a/webapp/components/LocaleSwitch/LocaleSwitch.vue b/webapp/components/LocaleSwitch/LocaleSwitch.vue index 156af4cb0..075e28579 100644 --- a/webapp/components/LocaleSwitch/LocaleSwitch.vue +++ b/webapp/components/LocaleSwitch/LocaleSwitch.vue @@ -90,7 +90,6 @@ export default { mutation: updateUserMutation(), variables: { id: this.currentUser.id, - name: this.currentUser.name, locale: this.$i18n.locale(), }, update: (store, { data: { UpdateUser } }) => { diff --git a/webapp/components/Upload/index.vue b/webapp/components/Upload/index.vue index 3b2106971..66e7203cc 100644 --- a/webapp/components/Upload/index.vue +++ b/webapp/components/Upload/index.vue @@ -66,7 +66,6 @@ export default { variables: { avatarUpload, id: this.user.id, - name: this.user.name, }, }) .then(() => { diff --git a/webapp/pages/settings/embeds.vue b/webapp/pages/settings/embeds.vue index 516a36262..d842dbef0 100644 --- a/webapp/pages/settings/embeds.vue +++ b/webapp/pages/settings/embeds.vue @@ -72,7 +72,6 @@ export default { mutation: updateUserMutation(), variables: { id: this.currentUser.id, - name: this.currentUser.name, allowEmbedIframes: !this.disabled, }, update: (store, { data: { UpdateUser } }) => { diff --git a/webapp/pages/settings/privacy.vue b/webapp/pages/settings/privacy.vue index 8a60f28df..3decdefbe 100644 --- a/webapp/pages/settings/privacy.vue +++ b/webapp/pages/settings/privacy.vue @@ -39,7 +39,6 @@ export default { mutation: updateUserMutation(), variables: { id: this.currentUser.id, - name: this.currentUser.name, showShoutsPublicly: this.shoutsAllowed, }, update: (_, { data: { UpdateUser } }) => { diff --git a/webapp/pages/terms-and-conditions-confirm.vue b/webapp/pages/terms-and-conditions-confirm.vue index 9a0c89821..24af8a23d 100644 --- a/webapp/pages/terms-and-conditions-confirm.vue +++ b/webapp/pages/terms-and-conditions-confirm.vue @@ -70,7 +70,6 @@ export default { mutation: updateUserMutation(), variables: { id: this.currentUser.id, - name: this.currentUser.name, termsAndConditionsAgreedVersion: VERSION, }, update: (store, { data: { UpdateUser } }) => {