From 2efc77097fcf44f034ccec99545634b3fd6ad2fb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 17 Apr 2019 14:49:03 +0200 Subject: [PATCH] match specification of Dennis - minimum 3 characters for username, no hint for user to change the username to "Anonymous", Toast error if userdata cannot be changed due to username restrictions, display "Anonymous" if no username is found in database (even tho this is against implemented rules) --- backend/src/middleware/userMiddleware.js | 5 ++ webapp/components/User/index.vue | 87 ++++++++---------------- webapp/locales/de.json | 5 +- webapp/locales/en.json | 5 +- webapp/pages/settings/index.vue | 44 +++++------- 5 files changed, 58 insertions(+), 88 deletions(-) diff --git a/backend/src/middleware/userMiddleware.js b/backend/src/middleware/userMiddleware.js index b3fc1bf2c..4789b4cbd 100644 --- a/backend/src/middleware/userMiddleware.js +++ b/backend/src/middleware/userMiddleware.js @@ -1,4 +1,5 @@ import dotenv from 'dotenv' +import { UserInputError } from 'apollo-server' import createOrUpdateLocations from './nodes/locations' @@ -12,6 +13,10 @@ export default { return result }, UpdateUser: async (resolve, root, args, context, info) => { + const USERNAME_MIN_LENGTH = 3 // TODO move to the correct place + if (!args.name || args.name.length < USERNAME_MIN_LENGTH) { + throw new UserInputError(`Username must be at least ${USERNAME_MIN_LENGTH} characters long!`) + } const result = await resolve(root, args, context, info) await createOrUpdateLocations(args.id, args.locationName, context.driver) return result diff --git a/webapp/components/User/index.vue b/webapp/components/User/index.vue index 6b0731981..2a3904763 100644 --- a/webapp/components/User/index.vue +++ b/webapp/components/User/index.vue @@ -3,65 +3,35 @@
- +
- Anonymus + {{ $t('profile.userAnonym') }}
- -