So i added a check to make it so you can't change your username to someone else's, also turns out Cherif already has a check so that if you change your username to someone else's 42 username who isn't a user yet and then they try to become a user, their username will have a random string attached to the end so it is also unique, then fixed a few minor things, and made it so all UnauthorizedPages take you back to / as in the SplashPage rather than a special page from which you navigate to /, that said, i think feedback for the user is kinda nice, will decide with team eventually

This commit is contained in:
Me
2023-01-07 01:41:06 +01:00
parent 0470676c5d
commit f7c728a009
5 changed files with 31 additions and 19 deletions

View File

@@ -9,7 +9,8 @@
console.error('conditionsFailed event', event.detail);
// i mean i guess i can just leave this in there permanently?
replace('/unauthorized-access');
// replace('/unauthorized-access');
replace('/');
};
</script>

View File

@@ -78,9 +78,11 @@
if (response.status === 200)
success.username = "Your changes have been saved"
else if (response.status === 201)
push("/2fa")
push("/2fa");
else if (response.status === 409)
errors.username = `${set.username} is already in use, pick a different one.`;
else
errors.username = "Something went wrong"
errors.username = "Something went wrong";
}
)
.catch((err) => errors.username = err)

View File

@@ -9,17 +9,12 @@
let avatar;
// avatar needs to be updated!!!
console.log('Generate User Display, BEFORE on mount ' + avatar)
// add errors
let errors = {avatar: ''};
onMount( async() => {
console.log('Generate User Display, on mount ' + user.username)
// using this for now cuz for some reason there is yet to be a way to fet another person's avatar
// console.log('Generate User Display, on mount ' + user.username)
if (primary) {
// await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user/avatar?username=${user.username}`, {method: "GET"})
// .then(response => {return response.blob()})
// .then(data => {
// const url = URL.createObjectURL(data);
// avatar = url;
// });
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user/avatar`, {method: "GET"})
.then(response => {return response.blob()})
.then(data => {
@@ -27,8 +22,8 @@
avatar = url;
})
.catch(() => errors.avatar = 'Sorry your avatar could not be loaded' );
console.log('avatar: ')
console.log(avatar)
// console.log('avatar: ')
// console.log(avatar)
} else {
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user/avatar?username=${user.username}`, {method: "GET"})
.then(response => {return response.blob()})
@@ -40,6 +35,9 @@
}
})
/**** THIS IS BASICALLY ALL THE RANK LOGIC ERIC HAS MADE ****/
if (user.loseGame > user.winGame) {
rank = 'Bitch Ass Loser!'
} else if (user.loseGame === user.winGame) {
@@ -86,6 +84,7 @@
<!-- <img class="icon" src="img/default_user_icon.png" alt="default user icon"> -->
<!-- <img class="icon" src="{user.image_url}" alt="default user icon"> -->
<img class="avatar" src="{avatar}" alt="default user icon">
<div class="error">{errors.avatar}</div>
<div class="username">{user.username}</div>
<div class="rank">Rank:
<span class="glitter">
@@ -169,6 +168,11 @@
font-weight: bold;
}
.error{
font-size: 0.8em;
font-weight: bold;
color: red;
}
/* Glittery Star Stuff */