changements mineurs

This commit is contained in:
batche
2022-12-08 14:01:07 +01:00
parent 8c2df71cde
commit b00c9e1474

View File

@@ -52,22 +52,19 @@
}) })
const settingsHandler = async() => { const settingsHandler = async() => {
let valid = false;
// 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.trim() === '')) { if ((set.username.trim() === '') && set.tfa === user.isEnabledTwoFactorAuth) {
errors.username = 'Invalid new username'; errors.username = 'Invalid new username';
return; return;
} }
else if (set.username === user.username){ else if ((set.username.trim() === '') && set.tfa !== user.isEnabledTwoFactorAuth) {
errors.username = "You must choose a different username than the previous" set.username = user.username
return;
} }
else { else {
errors.username = ''; errors.username = '';
} }
const res = await fetch('http://transcendance:8080/api/v2/user',{ await fetch('http://transcendance:8080/api/v2/user',{
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'