diff --git a/Frontend/src/js/modals/profile.js b/Frontend/src/js/modals/profile.js index 87751ec..8a03627 100644 --- a/Frontend/src/js/modals/profile.js +++ b/Frontend/src/js/modals/profile.js @@ -6,6 +6,17 @@ import { togglePasswordForm, handlePasswordUpdate } from './changePassword.js'; import { toggleProfilePictureForm, handleProfilePictureUpdate } from './changeProfilePicture.js'; import { showMessage } from './messages.js'; +function resetProfileForms() { + document.getElementById('updateEmailForm').style.display = 'none'; + document.getElementById('updatePasswordForm').style.display = 'none'; + document.getElementById('imageUploadForm').style.display = 'none'; + + document.getElementById('newEmail').value = ''; + document.getElementById('newPassword').value = ''; + document.getElementById('imageInput').value = ''; + document.getElementById('fileName').textContent = 'No file chosen'; +} + document.addEventListener('DOMContentLoaded', function () { updateUserProfile(); @@ -13,17 +24,6 @@ document.addEventListener('DOMContentLoaded', function () { if (profileModal) { profileModal.addEventListener('hide.bs.modal', resetProfileForms); } - - function resetProfileForms() { - document.getElementById('updateEmailForm').style.display = 'none'; - document.getElementById('updatePasswordForm').style.display = 'none'; - document.getElementById('imageUploadForm').style.display = 'none'; - - document.getElementById('newEmail').value = ''; - document.getElementById('newPassword').value = ''; - document.getElementById('imageInput').value = ''; - document.getElementById('fileName').textContent = 'No file chosen'; - } }); export function updateUserProfile() { @@ -163,6 +163,15 @@ export function updateUserProfile() { console.error('Error fetching user data:', error); }); } + handleTokenVerification() + .then(validToken => { + userData.token = validToken; + fetchProfile(userData); + + }) + .catch(error => { + console.error('Error verifying token:', error); + }); // Function to toggle 2FA status on the server function toggleTwoFactorAuth(userData, isEnabled, token) {