added the thing so you can see other people's avatars, fixed checks on frontend routes like game and such that other people created, need help understanding ValidationPipe() to make it so a user must have a unique username. TBH this shit is still being held together by Duct Tape and Holy Water
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
{#if user !== undefined}
|
||||
<GenerateUserDisplay user={user} primary={true}/>
|
||||
<GenerateUserDisplay user={user} primary={false}/>
|
||||
<!-- <GenerateUserDisplay user={user} primary={true}/> -->
|
||||
{:else}
|
||||
<h2>Sorry</h2>
|
||||
|
||||
@@ -4,20 +4,39 @@
|
||||
|
||||
|
||||
export let user;
|
||||
export let primary;
|
||||
export let primary; // kinda useless, not sure what i was going for... Might be userful after all
|
||||
let rank = '';
|
||||
let avatar;
|
||||
|
||||
// avatar needs to be updated!!!
|
||||
console.log('Generate User Display, BEFORE on mount ' + 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
|
||||
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 => {
|
||||
const url = URL.createObjectURL(data);
|
||||
avatar = url;
|
||||
});
|
||||
})
|
||||
.catch(() => errors.avatar = 'Sorry your avatar could not be loaded' );
|
||||
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()})
|
||||
.then(data => {
|
||||
const url = URL.createObjectURL(data);
|
||||
avatar = url;
|
||||
})
|
||||
.catch(() => errors.avatar = 'Sorry your avatar could not be loaded' );
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -13,9 +13,57 @@ import GameSpectator from '../pages/game/GameSpectator.svelte';
|
||||
export const primaryRoutes = {
|
||||
'/': SplashPage,
|
||||
'/2fa': TwoFactorAuthentication,
|
||||
'/game': Game,
|
||||
'/spectator': GameSpectator,
|
||||
'/ranking' : Ranking,
|
||||
'/game': wrap({
|
||||
component: Game,
|
||||
conditions: [
|
||||
async(detail) => {
|
||||
const user = await fetch('http://' + process.env.WEBSITE_HOST + ":" + process.env.WEBSITE_PORT + '/api/v2/user')
|
||||
.then((resp) => resp.json())
|
||||
|
||||
console.log('in /profile what is in user')
|
||||
console.log(user)
|
||||
|
||||
if (user && user.username)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
]
|
||||
}),
|
||||
'/spectator': wrap({
|
||||
component: GameSpectator,
|
||||
conditions: [
|
||||
async(detail) => {
|
||||
const user = await fetch('http://' + process.env.WEBSITE_HOST + ":" + process.env.WEBSITE_PORT + '/api/v2/user')
|
||||
.then((resp) => resp.json())
|
||||
|
||||
console.log('in /profile what is in user')
|
||||
console.log(user)
|
||||
|
||||
if (user && user.username)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
]
|
||||
}),
|
||||
'/ranking': wrap({
|
||||
component: Ranking,
|
||||
conditions: [
|
||||
async(detail) => {
|
||||
const user = await fetch('http://' + process.env.WEBSITE_HOST + ":" + process.env.WEBSITE_PORT + '/api/v2/user')
|
||||
.then((resp) => resp.json())
|
||||
|
||||
console.log('in /profile what is in user')
|
||||
console.log(user)
|
||||
|
||||
if (user && user.username)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
]
|
||||
}),
|
||||
'/profile': wrap({
|
||||
component: ProfilePage,
|
||||
conditions: [
|
||||
@@ -50,7 +98,6 @@ export const primaryRoutes = {
|
||||
}
|
||||
]
|
||||
}),
|
||||
|
||||
'/unauthorized-access': UnauthorizedAccessPage,
|
||||
'*': NotFound
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user