diff --git a/src/plugins/utils.js b/src/plugins/utils.js index 652ae68..1122cb8 100644 --- a/src/plugins/utils.js +++ b/src/plugins/utils.js @@ -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" ); diff --git a/src/services/matrix.service.js b/src/services/matrix.service.js index 1265a0c..ce0ac87 100644 --- a/src/services/matrix.service.js +++ b/src/services/matrix.service.js @@ -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, {