Prefix random usernames with "weblite"

This commit is contained in:
N Pex 2022-07-01 08:55:26 +00:00
parent fdfa9e902c
commit 6bd0d8ad7e
2 changed files with 8 additions and 4 deletions

View file

@ -389,8 +389,12 @@ class Util {
}
/** Generate a random user name */
randomUser() {
return "weblite-" + this.randomString(
randomUser(prefix) {
var pfx = prefix ? prefix.replace(/[^0-9a-zA-Z\-_]/gi, '') : null;
if (!pfx || pfx.length == 0) {
pfx = "weblite-";
}
return pfx + this.randomString(
12,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
);