Ok about to do some clean up
This commit is contained in:
@@ -50,8 +50,8 @@
|
|||||||
|
|
||||||
// to clean up local storage... as a precaution
|
// to clean up local storage... as a precaution
|
||||||
// this condition isn't good enough...
|
// this condition isn't good enough...
|
||||||
// if (user && user.statusCode && user.statusCode === 403) {
|
// if (user === undefined) {
|
||||||
if (user === undefined) {
|
if (user && user.statusCode && user.statusCode === 403) {
|
||||||
console.log('on mount no user, returned status code 403 so logging out of userStore')
|
console.log('on mount no user, returned status code 403 so logging out of userStore')
|
||||||
userLogout(); // which i think should delete any previous local storage
|
userLogout(); // which i think should delete any previous local storage
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
window.location.href = 'http://transcendance:8080/api/v2/auth';
|
window.location.href = 'http://transcendance:8080/api/v2/auth';
|
||||||
// await fetch ('http://transcendance:8080/api/v2/auth');
|
// await fetch ('http://transcendance:8080/api/v2/auth');
|
||||||
console.log('you are now logged in');
|
console.log('you are now logged in');
|
||||||
|
push('/profile')
|
||||||
|
|
||||||
// ok giving our new local storage and store combo a go
|
// ok giving our new local storage and store combo a go
|
||||||
// what i need is to set the store to the user when this button get's pressed
|
// what i need is to set the store to the user when this button get's pressed
|
||||||
@@ -83,6 +84,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// i could prolly put this in it's own compoent, i seem to use it in several places... or maybe just some JS? like no need for html
|
// i could prolly put this in it's own compoent, i seem to use it in several places... or maybe just some JS? like no need for html
|
||||||
|
// we could .then( () => replace('/') ) need the func so TS compatible...
|
||||||
const logout = async() => {
|
const logout = async() => {
|
||||||
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { push } from "svelte-spa-router";
|
import { push } from "svelte-spa-router";
|
||||||
|
import { userStore, userLogout } from "../stores/loginStatusStore";
|
||||||
|
|
||||||
// onMount( async() => {
|
// onMount( async() => {
|
||||||
// await fetch("http://transcendance:8080/api/v2/auth/2fa/generate",
|
// await fetch("http://transcendance:8080/api/v2/auth/2fa/generate",
|
||||||
@@ -59,9 +60,7 @@
|
|||||||
// The .then(push) doesn't seem to work...
|
// The .then(push) doesn't seem to work...
|
||||||
}
|
}
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// loginStatus.toggleTFA();
|
userLogout();
|
||||||
loginStatus.update( (old) => ({...old, tfa: true}) );
|
|
||||||
//
|
|
||||||
push('/profile');
|
push('/profile');
|
||||||
console.log('vaid Code for 2FA')
|
console.log('vaid Code for 2FA')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,9 @@
|
|||||||
rank = 'Yea you da Boss!'
|
rank = 'Yea you da Boss!'
|
||||||
}
|
}
|
||||||
|
|
||||||
await fetch("http://transcendance:8080/api/v2/user/avatar", {method: "GET"}).
|
await fetch("http://transcendance:8080/api/v2/user/avatar", {method: "GET"})
|
||||||
then(response => {return response.blob()}).
|
.then(response => {return response.blob()})
|
||||||
then(data => {
|
.then(data => {
|
||||||
const url = URL.createObjectURL(data);
|
const url = URL.createObjectURL(data);
|
||||||
avatar = url;
|
avatar = url;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,13 +5,15 @@
|
|||||||
import { push } from 'svelte-spa-router';
|
import { push } from 'svelte-spa-router';
|
||||||
|
|
||||||
let user;
|
let user;
|
||||||
|
let avatar, postVar, newAvatar, fileinput;
|
||||||
|
let uploadAvatarSuccess = false;
|
||||||
|
|
||||||
// tbh i might not need this...
|
// tbh i might not need this...
|
||||||
let set = {
|
let set = {
|
||||||
username: '',
|
username: '',
|
||||||
isChecked: false,
|
isChecked: false,
|
||||||
}
|
}
|
||||||
const errors = { username: '', checkbox: ''};
|
const errors = { username: '', checkbox: '', avatar: ''};
|
||||||
// let isChecked;
|
// let isChecked;
|
||||||
let testChecked = true;
|
let testChecked = true;
|
||||||
|
|
||||||
@@ -53,18 +55,18 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// $: uploadAvatar = async() => {
|
const uploadAvatar = async() => {
|
||||||
// const data = new FormData();
|
const data = new FormData();
|
||||||
// data.append("file", newAvatar[0]);
|
data.append("file", newAvatar[0]);
|
||||||
// console.log(data);
|
console.log(data);
|
||||||
// await fetch("http://transcendance:8080/api/v2/user/avatar",
|
await fetch("http://transcendance:8080/api/v2/user/avatar",
|
||||||
// {
|
{
|
||||||
// method : 'POST',
|
method : 'POST',
|
||||||
// body : data,
|
body : data,
|
||||||
// })
|
})
|
||||||
// .then(uploadAvatarSuccess = true)
|
.then(() => uploadAvatarSuccess = true) // for some reason it needs to be a function, i think a TS thing, not a promis otherwise
|
||||||
// .catch(errors.image_urlSv = "Something went wrong." )
|
.catch(() => errors.avatar = "Something went wrong." )
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="outter">
|
<!-- <div class="outter"> -->
|
||||||
<h2>Look, you can change stuff</h2>
|
<h2>Look, you can change stuff</h2>
|
||||||
<!-- maybe ues a card? -->
|
<!-- maybe ues a card? -->
|
||||||
<!-- a form? -->
|
<!-- a form? -->
|
||||||
@@ -88,21 +90,34 @@
|
|||||||
<input type="text" placeholder="new username" bind:value={set.username}>
|
<input type="text" placeholder="new username" bind:value={set.username}>
|
||||||
<div class="error">{errors.username}</div>
|
<div class="error">{errors.username}</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="form-field">
|
<div class="form-field">
|
||||||
<div class="label">Set Two Factor Authentication</div>
|
<div class="label">Set Two Factor Authentication</div>
|
||||||
<input type="checkbox" bind:checked={set.isChecked}>
|
<input type="checkbox" bind:checked={set.isChecked}>
|
||||||
<div class="error">{errors.checkbox}</div>
|
<div class="error">{errors.checkbox}</div>
|
||||||
</div> -->
|
</div>
|
||||||
<div class="form-field">
|
<!-- <div class="form-field">
|
||||||
<div class="label">Test</div>
|
<div class="label">Test</div>
|
||||||
<input type="checkbox" bind:checked={testChecked}>
|
<input type="checkbox" bind:checked={testChecked}>
|
||||||
<!-- This does work :) -->
|
</div> -->
|
||||||
</div>
|
|
||||||
<button>Update Settings</button>
|
<button>Update Settings</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
|
||||||
|
<Card>
|
||||||
|
<form on:submit|preventDefault={uploadAvatar}>
|
||||||
|
{#if avatar}
|
||||||
|
<img class="avatar" src={avatar} alt="your avatar"/>
|
||||||
|
{/if}
|
||||||
|
<input type="text" bind:value={postVar} placeholder={"choose your file"}/>
|
||||||
|
<br />
|
||||||
|
<input type="file" bind:files={newAvatar}/>
|
||||||
|
<br />
|
||||||
|
<button type="submit">Choose avatar</button>
|
||||||
|
</form>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<!-- </div> -->
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,12 @@
|
|||||||
let handleClickLogout = async () => {
|
let handleClickLogout = async () => {
|
||||||
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
})
|
||||||
|
.then( () => userLogout() ) // i think for TS reasons it has to be a func not direclty push('/') or whatever
|
||||||
|
.then( () => push('/') )
|
||||||
console.log('clicked logout header')
|
console.log('clicked logout header')
|
||||||
userLogout();
|
// userLogout();
|
||||||
push('/'); // replace?
|
// push('/'); // replace?
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user