From 192dcb7f4663b295f704b2c077c8c41fd64e33cd Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 31 Dec 2021 17:12:07 +0100 Subject: [PATCH] [editor] Prevent adding invalid usernames as channel / editor Signed-off-by: Knut Ahlers --- src/const.js | 2 ++ src/generalConfig.vue | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/const.js b/src/const.js index 850fa88..8ecace1 100644 --- a/src/const.js +++ b/src/const.js @@ -22,3 +22,5 @@ export const NOTIFY_CONFIG_RELOAD = 'configReload' export const NOTIFY_ERROR = 'error' export const NOTIFY_FETCH_ERROR = 'fetchError' export const NOTIFY_LOADING_DATA = 'loadingData' + +export const REGEXP_USER = /^[a-z0-9_]{4,25}$/ diff --git a/src/generalConfig.vue b/src/generalConfig.vue index c595aea..3877e66 100644 --- a/src/generalConfig.vue +++ b/src/generalConfig.vue @@ -56,11 +56,13 @@ this.$bus.$emit(constants.NOTIFY_FETCH_ERROR, err)) }, + + validateUserName(user) { + return user.match(constants.REGEXP_USER) + }, }, mounted() {