Skip to content

Commit

Permalink
fixed issue because i didn't call fetchprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicktvdd committed Aug 23, 2024
1 parent 4b88dbd commit 4b0bbf9
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions Frontend/src/js/modals/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ 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();

const profileModal = document.getElementById('ProfileModal');
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() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4b0bbf9

Please sign in to comment.