|
|
@ -45,12 +45,12 @@ function spawnNotification(body, title) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async function submitUsername() {
|
|
|
|
async function submitUsername() {
|
|
|
|
let unameInput = document.querySelector('#input-username');
|
|
|
|
let unameInput = document.querySelector('#input-username');
|
|
|
|
let username = unameInput.value.replace(/^\s+|\s+$/g, '');
|
|
|
|
let username = unameInput.value;
|
|
|
|
|
|
|
|
|
|
|
|
if (username.length > 1) {
|
|
|
|
if (username.length > 1 && username.length <= 30) {
|
|
|
|
return await setUsername(username);
|
|
|
|
return await setUsername(username);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
showError('You need to provide a username (minimum 2 characters)!');
|
|
|
|
showError('You need to provide a username (min. 2 characters, max. 30)!');
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,7 +61,8 @@ async function submitUsername() {
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async function setUsername(username) {
|
|
|
|
async function setUsername(username) {
|
|
|
|
let uname = username.substring(0, 30).replace(/[^\w- ;[\]]/g, '');
|
|
|
|
username = username.replace(/^\s+|\s+$/g, '');
|
|
|
|
|
|
|
|
let uname = username.replace(/[\n\t👑🌟]|^\s+|\s+$/gu, '');
|
|
|
|
if (uname.length === username.length) {
|
|
|
|
if (uname.length === username.length) {
|
|
|
|
let response = await postGraphqlQuery(`
|
|
|
|
let response = await postGraphqlQuery(`
|
|
|
|
mutation($username:String!) {
|
|
|
|
mutation($username:String!) {
|
|
|
@ -83,7 +84,7 @@ async function setUsername(username) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
showError('Your username contains illegal characters.');
|
|
|
|
showError(`Your username contains illegal characters (${username.replace(uname, '')}).`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|