Correction d'un autre bug mais dans la bonne fonction de luke.
This commit is contained in:
@@ -30,57 +30,13 @@
|
|||||||
set.tfa = user.isEnabledTwoFactorAuth;
|
set.tfa = user.isEnabledTwoFactorAuth;
|
||||||
})
|
})
|
||||||
|
|
||||||
const settingsHandler = async() => {
|
|
||||||
if ((set.username.trim() === '')) {
|
|
||||||
set.username = user.username
|
|
||||||
}
|
|
||||||
errors.username = ''
|
|
||||||
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`, {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
"username": set.username,
|
|
||||||
"isEnabledTwoFactorAuth": set.tfa
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
if (response.status === 200)
|
|
||||||
{
|
|
||||||
errors.username = ''
|
|
||||||
success.username = "Your changes have been saved"
|
|
||||||
}
|
|
||||||
else if (response.status === 201)
|
|
||||||
push("/2fa");
|
|
||||||
else if (response.status === 409)
|
|
||||||
{
|
|
||||||
success.username = ''
|
|
||||||
errors.username = `${set.username} is already in use, pick a different one.`;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
success.username = ''
|
|
||||||
errors.username = "Something went wrong";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch((err) => errors.username = err)
|
|
||||||
const settingsHandler = async() =>
|
const settingsHandler = async() =>
|
||||||
{
|
{
|
||||||
// TODO Luke <--> Eric : Explications
|
|
||||||
// I don't really care which i use at this point...
|
if ((set.username.trim() === '')) {
|
||||||
// if (set.username === nameTmp) {
|
|
||||||
if ((set.username.trim() === '') && set.tfa === user.isEnabledTwoFactorAuth) {
|
|
||||||
errors.username = 'Invalid new username';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ((set.username.trim() === '') && set.tfa !== user.isEnabledTwoFactorAuth) {
|
|
||||||
set.username = user.username
|
set.username = user.username
|
||||||
}
|
}
|
||||||
else {
|
errors.username = ''
|
||||||
errors.username = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`,
|
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`,
|
||||||
{
|
{
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -95,6 +51,7 @@
|
|||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
success.username = ''
|
||||||
errors.username = "Something went wrong";
|
errors.username = "Something went wrong";
|
||||||
if (response.status === 409) {
|
if (response.status === 409) {
|
||||||
errors.username = `${set.username} is already in use, pick a different one.`;
|
errors.username = `${set.username} is already in use, pick a different one.`;
|
||||||
@@ -103,6 +60,7 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
errors.username = ''
|
||||||
success.username = "Your changes have been saved";
|
success.username = "Your changes have been saved";
|
||||||
}
|
}
|
||||||
else if (response.status === 201) {
|
else if (response.status === 201) {
|
||||||
|
|||||||
Reference in New Issue
Block a user