added email verification
This commit is contained in:
+17
-14
@@ -1,22 +1,27 @@
|
||||
let id = '';
|
||||
let departmentId = '';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async function () {
|
||||
const {email, password, name} = await window.electronAPI.readUserConfig('user_info');
|
||||
const {id: userId, name, email, departmentId: userDepartmentId} = await window.databaseAPI.getUserInfo();
|
||||
|
||||
const emailInput = document.querySelector('input[name="email"]');
|
||||
const usernameInput = document.querySelector('input[name="username"]');
|
||||
const passwordInput = document.querySelector('input[name="password"]');
|
||||
|
||||
// Pre-fill form fields with existing data
|
||||
emailInput.value = email;
|
||||
id = userId
|
||||
departmentId = userDepartmentId;
|
||||
usernameInput.value = name;
|
||||
passwordInput.value = password;
|
||||
emailInput.value = email;
|
||||
passwordInput.value = '';
|
||||
|
||||
const backButton = document.getElementById('back');
|
||||
const submitButton = document.getElementById('submit');
|
||||
|
||||
// Get operation codes from the backend
|
||||
const operationCodes = await window.electronAPI.getOperationsCodes();
|
||||
const operationCodes = await window.networkAPI.getOperationsCodes();
|
||||
if (!operationCodes) {
|
||||
await window.electronAPI.showAlert('Internal error of the application.');
|
||||
await window.uiAPI.showAlert('Internal error of the application.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,8 +44,7 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
const name = usernameInput.value;
|
||||
const password = passwordInput.value;
|
||||
|
||||
const { id, departmentId } = await window.electronAPI.readUserConfig('user_info'); // Fetch login data
|
||||
const app_type = await window.electronAPI.readUserConfig('app_type'); // Fetch app type
|
||||
const app_type = await window.databaseAPI.getAppType();
|
||||
|
||||
// Prepare the data to be sent via the UC socket
|
||||
const messageData = {
|
||||
@@ -49,18 +53,18 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
email: email,
|
||||
password: password,
|
||||
departmentId: departmentId,
|
||||
app_type: app_type // Include app_type in the payload
|
||||
app_type: app_type
|
||||
};
|
||||
|
||||
// Open UC socket
|
||||
if (!await window.electronAPI.openUcSocket()) {
|
||||
await window.electronAPI.showAlert('Failed to open socket. Internal error of the application.');
|
||||
if (!await window.networkAPI.openUcSocket()) {
|
||||
await window.uiAPI.showAlert('Failed to open socket. Internal error of the application.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the message to the server using the UC socket
|
||||
if (!await window.electronAPI.sendUcMessage(codeModifyUser, messageData)) {
|
||||
await window.electronAPI.showAlert('Failed to send message.');
|
||||
if (!await window.networkAPI.sendUcMessage(codeModifyUser, messageData)) {
|
||||
await window.uiAPI.showAlert('Failed to send message.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,8 +74,7 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||
console.log('User update successful.');
|
||||
|
||||
// Save updated user info to the userConfig
|
||||
await window.electronAPI.writeUserConfig('user_credentials', { email: email, password: password });
|
||||
await window.electronAPI.writeUserConfig('user_info', {id: id, departmentId: departmentId, name: name});
|
||||
await window.databaseAPI.writeUserInfo({ id: id, email: email, name: name, departmentId: departmentId });
|
||||
|
||||
// Navigate back to the main menu
|
||||
fadeOut('main_menu');
|
||||
|
||||
Reference in New Issue
Block a user