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') }}
- -