added a few things back that i had deleted before when fixing 502, mainly looking at login fetch, so far everything works, no 502 and livereload is sorta a thing
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
<script lang="ts">
|
||||
import Canvas from "./components/Canvas.svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { push } from "svelte-spa-router";
|
||||
// import axios from 'axios';
|
||||
import { onMount } from 'svelte';
|
||||
import { loginStatus } from './stores/loginStatusStore.js';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
let dispatch = createEventDispatcher();
|
||||
// tmp for testing
|
||||
let aData = {
|
||||
username: '',
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
// console.log('PROFIL SVELTE');
|
||||
console.log('SplashPage testing if logged in')
|
||||
// const {data} = await axios.get('http://transcendance:8080/api/v2/user');
|
||||
fetch('http://transcendance:8080/api/v2/user')
|
||||
.then((resp) => resp.json())
|
||||
.then((res) => {
|
||||
aData.username = res.username;
|
||||
})
|
||||
console.log(aData);
|
||||
// if (data) {
|
||||
// $loginStatus = true;
|
||||
// push('/user');
|
||||
// //push('/user');
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -25,13 +31,15 @@
|
||||
window.location.href = 'http://transcendance:8080/api/v2/auth';
|
||||
// await fetch ('http://transcendance:8080/api/v2/auth');
|
||||
console.log('you are now logged in');
|
||||
push('/profile');
|
||||
//push('/profile');
|
||||
// it doesn't wait before changing the page tho which is really annoying... maybe the backend needs to be updated idk
|
||||
// cuz rn i'm doing it in the front and that doesn't seem great...
|
||||
}
|
||||
|
||||
const logout = async() => {
|
||||
await fetch('http://transcendance:8080/api/v2/auth/logout',);
|
||||
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
||||
method: 'POST',
|
||||
});
|
||||
$loginStatus = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,22 +9,24 @@
|
||||
import active from 'svelte-spa-router/active'
|
||||
// or i could leave them all and not display if they're active?
|
||||
|
||||
// import { createEventDispatcher } from 'svelte';
|
||||
|
||||
// let dispatch = createEventDispatcher();
|
||||
|
||||
|
||||
let handleClickHome = () => {
|
||||
// dispatch('clickedHome');
|
||||
// profile?
|
||||
console.log('clicked home')
|
||||
push('/profile');
|
||||
};
|
||||
|
||||
let handleClickLogout = () => {
|
||||
let handleClickLogout = async () => {
|
||||
// dispatch('clickedLogout');
|
||||
fetch ('http://transcendance:8080/api/v2/auth/logout');
|
||||
push('/');
|
||||
$loginStatus = false;
|
||||
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
||||
method: 'POST',
|
||||
});
|
||||
console.log('clicked logout header')
|
||||
$loginStatus = false;
|
||||
|
||||
// push('/');
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user