Disallow internal domains from being claimed

This commit is contained in:
Raven Scott
2025-12-26 17:48:50 -05:00
parent 02a11bc025
commit 10d7d52079
7 changed files with 119 additions and 8 deletions
+14 -2
View File
@@ -24,7 +24,17 @@ async function submitAddDomain() {
body: JSON.stringify({ domain, hash, ssl })
});
if (!response.ok) {
throw new Error(await response.text());
const errorText = await response.text();
let errorMessage = errorText;
// Try to parse as JSON and extract the message
try {
const errorJson = JSON.parse(errorText);
errorMessage = errorJson.message || errorText;
} catch (e) {
// If not JSON, use the text as-is
errorMessage = errorText;
}
throw new Error(errorMessage);
}
if (window.showNotification) window.showNotification('Domain added successfully');
const modal = document.getElementById('addDomainModal');
@@ -35,7 +45,9 @@ async function submitAddDomain() {
if (window.genericFetch) window.genericFetch('domains', true);
} catch (err) {
console.error('Failed to add domain:', err);
if (window.showNotification) window.showNotification('Failed to add domain: ' + err.message, 'error');
// Display just the error message, not the full error object
const errorMessage = err.message || 'An unknown error occurred';
if (window.showNotification) window.showNotification(errorMessage, 'error');
}
}
+27 -1
View File
@@ -1,6 +1,27 @@
// Notification and confirmation dialog functions
function showNotification(message, type = 'success') {
const container = document.getElementById('notifications');
// Check if any dialog is open
const openDialog = document.querySelector('dialog[open]');
// If a dialog is open, append notifications directly to the dialog element
// This ensures they appear above the backdrop since they're children of the dialog
// Otherwise, use the regular notifications container
let container;
if (openDialog) {
// Check if notification container already exists in the dialog
let dialogNotificationContainer = openDialog.querySelector('.dialog-notifications');
if (!dialogNotificationContainer) {
dialogNotificationContainer = document.createElement('div');
dialogNotificationContainer.className = 'dialog-notifications';
// Append directly to dialog element (not inside content)
// This ensures it's in the dialog's stacking context above the backdrop
openDialog.appendChild(dialogNotificationContainer);
}
container = dialogNotificationContainer;
} else {
container = document.getElementById('notifications');
}
if (!container) return;
const notification = document.createElement('div');
let bgColor = 'bg-green-500';
@@ -13,6 +34,7 @@ function showNotification(message, type = 'success') {
bgColor,
'transition-all', 'duration-300', 'opacity-0', 'transform', 'translate-y-4'
);
notification.style.cssText = 'pointer-events: auto;';
notification.textContent = message;
container.appendChild(notification);
setTimeout(() => {
@@ -24,6 +46,10 @@ function showNotification(message, type = 'success') {
notification.classList.add('opacity-0', 'translate-y-4');
setTimeout(() => {
notification.remove();
// Clean up dialog notification container if empty
if (openDialog && container.classList.contains('dialog-notifications') && container.children.length === 0) {
container.remove();
}
}, 300);
}, 3000);
}