pushing to master, only minor changes

This commit is contained in:
Me
2022-12-08 17:04:50 +01:00
parent d2f45ba86a
commit 8688f3b48f
5 changed files with 29 additions and 12 deletions

View File

@@ -26,10 +26,11 @@
// i think i don't need to do this once i sort out the {wrap} conditions: in theory i could pass values to the Route
// once the async authentication check is done
onMount( async() => {
// so ideally i wouldn't do this
// console.log('mounting profile display')
user = await fetch('http://transcendance:8080/api/v2/user')
.then( (x) => x.json() );
// console.log('profile display did my fetch')
// should i be updating the userStore or is that unnecessary?
if (user.loseGame > user.winGame) {

View File

@@ -24,7 +24,7 @@
}
// i don't unerstand why this is necessary but it really doesn't like it otherwise
nameTmp = user.username;
// console.log(user.username)
console.log(user.username)
set.tfa = user.isEnabledTwoFactorAuth;
@@ -54,7 +54,9 @@
// I don't really care which i use at this point...
// if (set.username === nameTmp) {
if (set.username === user.username || (set.username !== '' && set.username.trim() === '')) {
// if (set.username === user.username || (set.username !== '' && set.username.trim() === '')) {
// if (set.username !== '' && set.username.trim() === '') {
if (set.username === undefined || (set.username !== '' && set.username.trim() === '')) {
errors.username = 'Invalid new username';
valid = false;
} else {
@@ -62,24 +64,35 @@
valid = true;
}
if (set.username === '') {
set.username === nameTmp;
// set.username === user.username;
// set.username = nameTmp;
set.username = user.username;
}
console.log("valid is " + valid)
console.log("username is " + set.username)
if (valid) {
await fetch('http://transcendance:8080/api/v2/user',{
console.log('settings valid about to fetch')
const response = await fetch('http://transcendance:8080/api/v2/user',
{
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"username": set.username,
"isEnabledTwoFactorAuth": set.tfa
"isEnabledTwoFactorAuth": set.tfa
})
})
.then(response => response.json())
// .then((result) => console.log(result))
})
// .then(() => push('/profile'))
// .then(response => response.json())
// .then((result) => console.log("this is result " + result))
// .then(() => console.log('successful sub of new settings'))
console.log('end of settings is valid')
// if (response.status === 200) {
// push('/profile');
// console.log('valid Code for 2FA')
// }
}
};

View File

@@ -10,6 +10,8 @@
await fetch('http://transcendance:8080/api/v2/auth/logout', {
method: 'POST',
})
// .then(resp => resp.json)
// .then((resp) => console.log(resp))
.then( () => push('/') ) // i think for TS reasons it has to be a func not direclty push('/') or whatever
console.log('clicked logout header')
};