pushing to master, only minor changes
This commit is contained in:
@@ -75,7 +75,8 @@ export class UsersController {
|
|||||||
console.log("On est dans la boucle de redirection 2FA / Au niveau de l'update du user")
|
console.log("On est dans la boucle de redirection 2FA / Au niveau de l'update du user")
|
||||||
return response.status(200).redirect("http://transcendance:8080/#/2fa");
|
return response.status(200).redirect("http://transcendance:8080/#/2fa");
|
||||||
}
|
}
|
||||||
return response.status(200).redirect("http://transcendance:8080/#/profile")
|
return response.status(200).redirect("http://transcendance:8080/#/profile");
|
||||||
|
// return response.status(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthenticateGuard)
|
@UseGuards(AuthenticateGuard)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { writable } from "svelte/store";
|
|||||||
let _user = localStorage.getItem('42User');
|
let _user = localStorage.getItem('42User');
|
||||||
|
|
||||||
// turns out a simple store is actually the easiest :)
|
// turns out a simple store is actually the easiest :)
|
||||||
export const userStore = writable(_user ? JSON.parse(_user) : null); // we start with no user, but go get one if one exists
|
// export const userStore = writable(_user ? JSON.parse(_user) : null); // we start with no user, but go get one if one exists
|
||||||
// export const userStore = writable(null);
|
// export const userStore = writable(null);
|
||||||
|
|
||||||
// ok so this will happen no matter what, basically we are telling it what to do if the store containing the user changes
|
// ok so this will happen no matter what, basically we are telling it what to do if the store containing the user changes
|
||||||
|
|||||||
@@ -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
|
// 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
|
// once the async authentication check is done
|
||||||
onMount( async() => {
|
onMount( async() => {
|
||||||
// so ideally i wouldn't do this
|
// console.log('mounting profile display')
|
||||||
user = await fetch('http://transcendance:8080/api/v2/user')
|
user = await fetch('http://transcendance:8080/api/v2/user')
|
||||||
.then( (x) => x.json() );
|
.then( (x) => x.json() );
|
||||||
|
|
||||||
|
// console.log('profile display did my fetch')
|
||||||
// should i be updating the userStore or is that unnecessary?
|
// should i be updating the userStore or is that unnecessary?
|
||||||
|
|
||||||
if (user.loseGame > user.winGame) {
|
if (user.loseGame > user.winGame) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
// i don't unerstand why this is necessary but it really doesn't like it otherwise
|
// i don't unerstand why this is necessary but it really doesn't like it otherwise
|
||||||
nameTmp = user.username;
|
nameTmp = user.username;
|
||||||
// console.log(user.username)
|
console.log(user.username)
|
||||||
|
|
||||||
set.tfa = user.isEnabledTwoFactorAuth;
|
set.tfa = user.isEnabledTwoFactorAuth;
|
||||||
|
|
||||||
@@ -54,7 +54,9 @@
|
|||||||
|
|
||||||
// I don't really care which i use at this point...
|
// I don't really care which i use at this point...
|
||||||
// if (set.username === nameTmp) {
|
// 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';
|
errors.username = 'Invalid new username';
|
||||||
valid = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -62,24 +64,35 @@
|
|||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
if (set.username === '') {
|
if (set.username === '') {
|
||||||
set.username === nameTmp;
|
// set.username = nameTmp;
|
||||||
// set.username === user.username;
|
set.username = user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("valid is " + valid)
|
||||||
|
console.log("username is " + set.username)
|
||||||
|
|
||||||
if (valid) {
|
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',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"username": set.username,
|
"username": set.username,
|
||||||
"isEnabledTwoFactorAuth": set.tfa
|
"isEnabledTwoFactorAuth": set.tfa
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
// .then(() => push('/profile'))
|
||||||
// .then((result) => console.log(result))
|
// .then(response => response.json())
|
||||||
|
// .then((result) => console.log("this is result " + result))
|
||||||
// .then(() => console.log('successful sub of new settings'))
|
// .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')
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
await fetch('http://transcendance:8080/api/v2/auth/logout', {
|
||||||
method: 'POST',
|
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
|
.then( () => push('/') ) // i think for TS reasons it has to be a func not direclty push('/') or whatever
|
||||||
console.log('clicked logout header')
|
console.log('clicked logout header')
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user