password reset online test

This commit is contained in:
2025-06-20 13:18:13 +02:00
parent e25c7660b0
commit c9d1d7416b
3 changed files with 513 additions and 65 deletions

View File

@@ -171,6 +171,18 @@ function initializeSteps() {
</div>
`;
stepsContainer.appendChild(credentialsStep);
// Add Send Completion Email step
const emailStep = document.createElement('div');
emailStep.className = 'step-item';
emailStep.innerHTML = `
<div class="step-icon"><i class="fas fa-envelope"></i></div>
<div class="step-content">
<h5>Send Completion Email</h5>
<p class="step-status">Sending notification to client...</p>
</div>
`;
stepsContainer.appendChild(emailStep);
}
async function startLaunch(data) {
@@ -633,7 +645,12 @@ async function startLaunch(data) {
const credentialsStep = document.querySelectorAll('.step-item')[12];
credentialsStep.classList.remove('active');
credentialsStep.classList.add('completed');
credentialsStep.querySelector('.step-status').textContent = 'Successfully updated admin credentials';
if (credentialsResult.data.already_updated) {
credentialsStep.querySelector('.step-status').textContent = 'Admin credentials already updated';
} else {
credentialsStep.querySelector('.step-status').textContent = 'Successfully updated admin credentials';
}
// Add credentials details
const credentialsDetails = document.createElement('div');
@@ -641,7 +658,7 @@ async function startLaunch(data) {
credentialsDetails.innerHTML = `
<div class="card">
<div class="card-body">
<h6 class="card-title mb-3">Admin Credentials Updated</h6>
<h6 class="card-title mb-3">${credentialsResult.data.already_updated ? 'Admin Credentials Status' : 'Admin Credentials Updated'}</h6>
<div class="table-responsive">
<table class="table table-sm">
<thead>
@@ -667,12 +684,19 @@ async function startLaunch(data) {
<td>Role</td>
<td><span class="badge bg-primary">Administrator</span></td>
</tr>
<tr>
<td>Status</td>
<td><span class="badge bg-${credentialsResult.data.already_updated ? 'info' : 'success'}">${credentialsResult.data.already_updated ? 'Already Updated' : 'Updated'}</span></td>
</tr>
</tbody>
</table>
</div>
<div class="alert alert-warning mt-3">
<i class="fas fa-exclamation-triangle me-2"></i>
<strong>Important:</strong> Please save these credentials securely. The password will not be shown again.
<div class="alert alert-${credentialsResult.data.already_updated ? 'info' : 'warning'} mt-3">
<i class="fas fa-${credentialsResult.data.already_updated ? 'info-circle' : 'exclamation-triangle'} me-2"></i>
<strong>${credentialsResult.data.already_updated ? 'Note:' : 'Important:'}</strong>
${credentialsResult.data.already_updated ?
'Admin credentials were already updated from the default settings.' :
'Please save these credentials securely. The password will not be shown again.'}
</div>
<div class="alert alert-info mt-2">
<i class="fas fa-info-circle me-2"></i>
@@ -683,9 +707,68 @@ async function startLaunch(data) {
`;
credentialsStep.querySelector('.step-content').appendChild(credentialsDetails);
// Step 14: Send Completion Email
await updateStep(14, 'Send Completion Email', 'Sending notification to client...');
const emailResult = await sendCompletionEmail(`https://${data.webAddresses[0]}`, data.company, credentialsResult.data);
if (!emailResult.success) {
throw new Error(`Email sending failed: ${emailResult.error}`);
}
// Update the email step to show success
const emailStep = document.querySelectorAll('.step-item')[13];
emailStep.classList.remove('active');
emailStep.classList.add('completed');
emailStep.querySelector('.step-status').textContent = 'Successfully sent completion email';
// Add email details
const emailDetails = document.createElement('div');
emailDetails.className = 'mt-3';
emailDetails.innerHTML = `
<div class="card">
<div class="card-body">
<h6 class="card-title mb-3">Completion Email Sent</h6>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Recipient</td>
<td>${data.company.email || 'Not set'}</td>
</tr>
<tr>
<td>Subject</td>
<td>Your DocuPulse Instance is Ready!</td>
</tr>
<tr>
<td>Status</td>
<td><span class="badge bg-success">Sent Successfully</span></td>
</tr>
<tr>
<td>Instance URL</td>
<td><a href="https://${data.webAddresses[0]}" target="_blank">https://${data.webAddresses[0]}</a></td>
</tr>
</tbody>
</table>
</div>
<div class="alert alert-success mt-3">
<i class="fas fa-check-circle me-2"></i>
<strong>Launch Complete!</strong> Your DocuPulse instance has been successfully deployed and configured.
The client has been notified via email with all necessary login information.
</div>
</div>
</div>
`;
emailStep.querySelector('.step-content').appendChild(emailDetails);
} catch (error) {
console.error('Launch failed:', error);
await updateStep(13, 'Update Admin Credentials', `Error: ${error.message}`);
await updateStep(14, 'Send Completion Email', `Error: ${error.message}`);
showError(error.message);
}
}
@@ -1291,8 +1374,8 @@ function updateStep(stepNumber, title, description) {
document.getElementById('currentStep').textContent = title;
document.getElementById('stepDescription').textContent = description;
// Calculate progress based on total number of steps (13 steps total)
const totalSteps = 13;
// Calculate progress based on total number of steps (14 steps total)
const totalSteps = 14;
const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100;
const progressBar = document.getElementById('launchProgress');
progressBar.style.width = `${progress}%`;
@@ -1810,4 +1893,43 @@ async function updateAdminCredentials(instanceUrl, email) {
error: error.message
};
}
}
async function sendCompletionEmail(instanceUrl, company, credentials) {
try {
console.log('Sending completion email to:', company.email);
const response = await fetch('/api/admin/send-completion-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
},
body: JSON.stringify({
instance_url: instanceUrl,
company_data: company,
credentials_data: credentials
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to send completion email: ${errorText}`);
}
const result = await response.json();
console.log('Email sent successfully:', result);
return {
success: true,
message: result.message,
data: result.data
};
} catch (error) {
console.error('Error sending completion email:', error);
return {
success: false,
error: error.message
};
}
}