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"
);

View file

@ -115,7 +115,7 @@ export default {
// can not use avatars and 3. They can not seamlessly be upgraded to real accounts.
//
// Instead, we use an ILAG approach, Improved Landing as Guest.
const user = util.randomUser();
const user = util.randomUser(this.$config.userIdPrefix);
const pass = util.randomPass();
promiseLogin = tempMatrixClient
.register(user, pass, null, {
@ -854,7 +854,7 @@ export default {
if (tempUser) {
clientPromise = Promise.resolve(tempUser);
} else {
const user = util.randomUser();
const user = util.randomUser(this.$config.userIdPrefix);
const pass = util.randomPass();
clientPromise = tempMatrixClient
.register(user, pass, null, {