From 906e79f39bb2a1db9276b717bf53721cba0e3973 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 21 Feb 2018 17:29:22 +0200 Subject: [PATCH] Allow generating random numbers in nick on page load --- defaults/config.js | 3 +++ src/server.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/defaults/config.js b/defaults/config.js index 74c071e4..1f6d1273 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -236,6 +236,9 @@ module.exports = { // // Nick // + // Percent sign (%) will be replaced into a random number from 0 to 9. + // For example, Guest%%% will become Guest123 on page load. + // // @type string // @default "lounge-user" // diff --git a/src/server.js b/src/server.js index 05b341f8..0cef20ff 100644 --- a/src/server.js +++ b/src/server.js @@ -521,7 +521,7 @@ function getClientConfiguration() { config.themes = themes.getAll(); if (config.displayNetwork) { - config.defaults = Helper.config.defaults; + config.defaults = _.clone(Helper.config.defaults); } else { // Only send defaults that are visible on the client config.defaults = _.pick(Helper.config.defaults, [ @@ -533,6 +533,8 @@ function getClientConfiguration() { ]); } + config.defaults.nick = config.defaults.nick.replace(/%/g, () => Math.floor(Math.random() * 10)); + return config; }