Add domain status notifications & login alerts

Introduce richer notifications and domain status handling across the app.

- NotificationService: Add domain status alert formatting/sending, in-app notifications for available/registered/redemption/pending_delete, richer session_new and session_failed notifications (geolocation + UA parsing) and helpers for human-readable status labels.
- Auth/TwoFactor: Emit notifications for successful logins (including remember-me and 2FA) and failed login attempts; update last-login timestamp on various flows.
- DomainController: Wrap bulk domain create in try/catch to handle duplicate race conditions and log failures.
- WhoisService: Detect redemption_period and pending_delete statuses from WHOIS/EPP statuses.
- Settings/Setting: Add settings support for notification status triggers and bump default app_version to 1.1.2; persist/update status trigger values.
- Views/Layout/View helpers: Add parsing/formatting for login notification data, add new status labels/classes (available, redemption_period, pending_delete), update notification icons/colors mapping.
- Top-nav & Notifications UI: Enhance dropdown with rich login/failed-login display (flags, device icons), clickable domain redirects when marking read, badge IDs for dynamic updates.
- Error admin UI: Add copy error report button with robust clipboard fallback and toast UI reused from messages; improved copy UX in admin index/detail.
- Installer: Add new migration 024 to installer migration lists and adjust detected toVersion to 1.1.2.
- DB: Add migration file 024_add_status_notifications_v1.1.2.sql (new file).

These changes add user-facing alerts for domain lifecycle events and stronger login/security notifications while improving UI feedback and robustness during bulk operations.
This commit is contained in:
Hosteroid
2026-02-08 22:58:59 +02:00
parent f32de0a848
commit e334f7c9d6
24 changed files with 1597 additions and 200 deletions

View File

@@ -68,7 +68,10 @@ $currentFilters = $filters ?? ['search' => '', 'status' => '', 'group' => '', 's
<option value="">All Statuses</option>
<option value="active" <?= $currentFilters['status'] === 'active' ? 'selected' : '' ?>>Active</option>
<option value="expiring_soon" <?= $currentFilters['status'] === 'expiring_soon' ? 'selected' : '' ?>>Expiring Soon</option>
<option value="expired" <?= $currentFilters['status'] === 'expired' ? 'selected' : '' ?>>Expired</option>
<option value="available" <?= $currentFilters['status'] === 'available' ? 'selected' : '' ?>>Available</option>
<option value="redemption_period" <?= $currentFilters['status'] === 'redemption_period' ? 'selected' : '' ?>>Redemption Period</option>
<option value="pending_delete" <?= $currentFilters['status'] === 'pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
<option value="error" <?= $currentFilters['status'] === 'error' ? 'selected' : '' ?>>Error</option>
<option value="inactive" <?= $currentFilters['status'] === 'inactive' ? 'selected' : '' ?>>Inactive</option>
</select>

View File

@@ -9,14 +9,18 @@ $isResolved = (bool)$error['is_resolved'];
$errorTypeShort = substr(strrchr($error['error_type'], '\\'), 1) ?: $error['error_type'];
?>
<!-- Action Buttons -->
<!-- Back Navigation -->
<div class="mb-4 flex items-center justify-between">
<a href="/errors" class="text-gray-600 hover:text-primary">
<a href="/errors" class="inline-flex items-center px-3 py-2 border border-gray-300 text-gray-700 text-sm rounded-lg hover:bg-gray-50 transition-colors font-medium">
<i class="fas fa-arrow-left mr-2"></i>
Back to Error Logs
</a>
<div class="flex items-center space-x-2">
<button onclick="copyErrorReport()" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors text-sm font-medium">
<i class="fas fa-clipboard mr-2"></i>
Copy Error Report
</button>
<?php if ($isResolved): ?>
<form method="POST" action="/errors/<?= htmlspecialchars($error['error_id']) ?>/unresolve" class="inline">
<input type="hidden" name="csrf_token" value="<?= csrf_token() ?>">
@@ -354,31 +358,157 @@ function copyToClipboard(text) {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(() => {
showCopySuccess();
}).catch(() => {
fallbackCopy(text);
});
} else {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
showCopySuccess();
fallbackCopy(text);
}
}
function fallbackCopy(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
showCopySuccess();
} catch (err) {
console.error('Copy failed:', err);
}
document.body.removeChild(textArea);
}
function copyErrorReport() {
const errorType = <?= json_encode($error['error_type'] ?? 'Error') ?>;
const errorMessage = <?= json_encode($error['error_message'] ?? 'Unknown error') ?>;
const errorFile = <?= json_encode($error['error_file'] ?? 'Unknown') ?>;
const errorLine = <?= json_encode($error['error_line'] ?? '?') ?>;
const errorId = <?= json_encode($error['error_id'] ?? 'N/A') ?>;
const phpVersion = <?= json_encode($error['php_version'] ?? 'Unknown') ?>;
const memoryUsage = <?= json_encode($error['memory_usage'] ?? 'Unknown') ?>;
const requestMethod = <?= json_encode($error['request_method'] ?? 'GET') ?>;
const requestUri = <?= json_encode($error['request_uri'] ?? '/') ?>;
const userAgent = <?= json_encode($error['user_agent'] ?? 'Unknown') ?>;
const ipAddress = <?= json_encode($error['ip_address'] ?? 'Unknown') ?>;
const occurredAt = <?= json_encode(date('Y-m-d H:i:s', strtotime($error['occurred_at']))) ?>;
const lastOccurredAt = <?= json_encode(date('Y-m-d H:i:s', strtotime($error['last_occurred_at'] ?? $error['occurred_at']))) ?>;
const occurrences = <?= json_encode($error['occurrences'] ?? 1) ?>;
const isResolved = <?= json_encode($isResolved) ?>;
const requestData = <?= json_encode($error['request_data'] ?? null) ?>;
const sessionData = <?= json_encode($error['session_data'] ?? null) ?>;
// Get stack trace from the rendered elements
const traceFrames = document.querySelectorAll('#content-stack-trace .bg-gray-50');
let stackTrace = 'Not available';
if (traceFrames.length > 0) {
let traceLines = [];
traceFrames.forEach((frame, i) => {
const fileLine = frame.querySelector('.font-mono.text-xs');
const funcLine = frame.querySelector('.font-mono.text-sm');
let line = '#' + i + ' ';
if (fileLine) line += fileLine.textContent.trim().replace(/\s+/g, ' ');
if (funcLine) line += ' ' + funcLine.textContent.trim().replace(/\s+/g, '');
traceLines.push(line);
});
stackTrace = traceLines.join('\n');
}
// Format request data sections
let requestDataText = 'Not available';
if (requestData && typeof requestData === 'object' && Object.keys(requestData).length > 0) {
let sections = [];
for (const [key, value] of Object.entries(requestData)) {
sections.push(` [${key.toUpperCase()}]\n ${JSON.stringify(value, null, 2).split('\n').join('\n ')}`);
}
requestDataText = sections.join('\n\n');
}
// Format session data
let sessionDataText = 'Not available';
if (sessionData && typeof sessionData === 'object' && Object.keys(sessionData).length > 0) {
sessionDataText = ' ' + JSON.stringify(sessionData, null, 2).split('\n').join('\n ');
}
const errorReport = `=== DOMAIN MONITOR ERROR REPORT ===
ERROR INFORMATION:
- Error ID: ${errorId}
- Type: ${errorType}
- Message: ${errorMessage}
- Status: ${isResolved ? 'Resolved' : 'Unresolved'}
- Occurrences: ${occurrences}
LOCATION:
- File: ${errorFile}
- Line: ${errorLine}
REQUEST DETAILS:
- Method: ${requestMethod}
- URI: ${requestUri}
- IP Address: ${ipAddress}
- User Agent: ${userAgent}
- First Occurred: ${occurredAt}
- Last Occurred: ${lastOccurredAt}
REQUEST DATA:
${requestDataText}
SESSION DATA:
${sessionDataText}
SYSTEM INFORMATION:
- PHP Version: ${phpVersion}
- Memory Usage: ${memoryUsage}
STACK TRACE:
${stackTrace}
=== END OF ERROR REPORT ===
Reference ID: ${errorId}
Please include this report when reporting bugs.`;
copyToClipboard(errorReport);
}
function showCopySuccess() {
const message = document.createElement('div');
message.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-3 rounded-lg shadow-lg z-50 flex items-center';
message.innerHTML = '<i class="fas fa-check mr-2"></i>Copied to clipboard!';
document.body.appendChild(message);
// Use the existing toast container from messages.php
let container = document.getElementById('toast-container');
if (!container) {
container = document.createElement('div');
container.id = 'toast-container';
container.className = 'fixed bottom-4 right-4 z-[9999] space-y-3 max-w-sm';
document.body.appendChild(container);
}
const toast = document.createElement('div');
toast.className = 'toast bg-white border-l-4 border-green-500 rounded-lg shadow-lg p-4 flex items-start animate-slide-in';
toast.innerHTML = `
<div class="flex-shrink-0">
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
<i class="fas fa-check text-green-600 text-sm"></i>
</div>
</div>
<div class="ml-3 flex-1">
<p class="text-sm font-medium text-gray-900">Success</p>
<p class="text-sm text-gray-600 mt-0.5">Copied to clipboard!</p>
</div>
<button onclick="this.parentElement.remove()" class="ml-3 flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors">
<i class="fas fa-times text-sm"></i>
</button>
`;
container.appendChild(toast);
setTimeout(() => {
message.style.opacity = '0';
message.style.transition = 'opacity 0.3s';
setTimeout(() => message.remove(), 300);
}, 2000);
toast.style.transition = 'opacity 0.3s ease-out, transform 0.3s ease-out';
toast.style.opacity = '0';
toast.style.transform = 'translateX(100%)';
setTimeout(() => toast.remove(), 300);
}, 3000);
}
function markResolved() {

View File

@@ -432,16 +432,39 @@ function copyToClipboard(text) {
}
function showCopySuccess() {
const message = document.createElement('div');
message.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-3 rounded-lg shadow-lg z-50 flex items-center';
message.innerHTML = '<i class="fas fa-check mr-2"></i>Copied to clipboard!';
document.body.appendChild(message);
// Use the existing toast container from messages.php
let container = document.getElementById('toast-container');
if (!container) {
container = document.createElement('div');
container.id = 'toast-container';
container.className = 'fixed bottom-4 right-4 z-[9999] space-y-3 max-w-sm';
document.body.appendChild(container);
}
const toast = document.createElement('div');
toast.className = 'toast bg-white border-l-4 border-green-500 rounded-lg shadow-lg p-4 flex items-start animate-slide-in';
toast.innerHTML = `
<div class="flex-shrink-0">
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
<i class="fas fa-check text-green-600 text-sm"></i>
</div>
</div>
<div class="ml-3 flex-1">
<p class="text-sm font-medium text-gray-900">Success</p>
<p class="text-sm text-gray-600 mt-0.5">Copied to clipboard!</p>
</div>
<button onclick="this.parentElement.remove()" class="ml-3 flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors">
<i class="fas fa-times text-sm"></i>
</button>
`;
container.appendChild(toast);
setTimeout(() => {
message.style.opacity = '0';
message.style.transition = 'opacity 0.3s';
setTimeout(() => message.remove(), 300);
}, 2000);
toast.style.transition = 'opacity 0.3s ease-out, transform 0.3s ease-out';
toast.style.opacity = '0';
toast.style.transform = 'translateX(100%)';
setTimeout(() => toast.remove(), 300);
}, 3000);
}
let currentErrorId = null;

View File

@@ -74,7 +74,7 @@
<div class="flex items-center justify-between">
<h3 class="text-sm font-semibold text-gray-900">Notifications</h3>
<?php if ($unreadNotifications > 0): ?>
<span class="px-2 py-0.5 bg-orange-100 text-orange-700 text-xs font-semibold rounded"><?= $unreadNotifications ?> new</span>
<span id="dropdownHeaderBadge" class="px-2 py-0.5 bg-orange-100 text-orange-700 text-xs font-semibold rounded"><?= $unreadNotifications ?> new</span>
<?php endif; ?>
</div>
</div>
@@ -83,19 +83,84 @@
<div class="max-h-96 overflow-y-auto">
<?php if (!empty($recentNotifications)): ?>
<?php foreach ($recentNotifications as $notif): ?>
<div class="px-4 py-3 hover:bg-gray-50 border-b border-gray-100 bg-blue-50 transition-colors cursor-pointer">
<?php
// Build the click URL: if domain notification, go to domain; otherwise just mark as read
$hasDomain = !empty($notif['domain_id']);
$notifUrl = $hasDomain
? '/notifications/' . $notif['id'] . '/mark-read?redirect=domain&domain_id=' . $notif['domain_id']
: '/notifications/' . $notif['id'] . '/mark-read';
?>
<div class="px-4 py-3 hover:bg-gray-50 border-b border-gray-100 bg-blue-50 transition-colors notification-item" data-id="<?= $notif['id'] ?>">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 bg-<?= $notif['color'] ?>-100 rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-<?= $notif['icon'] ?> text-<?= $notif['color'] ?>-600 text-sm"></i>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<p class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($notif['title']) ?></p>
<span class="w-2 h-2 bg-blue-500 rounded-full"></span>
</div>
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notif['message']) ?></p>
<p class="text-xs text-gray-400 mt-1"><?= $notif['time_ago'] ?></p>
</div>
<?php $loginData = $notif['login_data'] ?? null; ?>
<?php if ($loginData && $notif['type'] === 'session_failed'): ?>
<!-- Failed login notification (mirrors successful login layout) -->
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
<?php if (($loginData['country_code'] ?? 'xx') !== 'xx'): ?>
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-base rounded-sm"></span>
<?php else: ?>
<i class="fas fa-shield-alt text-red-600 text-sm"></i>
<?php endif; ?>
</a>
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<p class="text-sm font-semibold text-red-700"><?= htmlspecialchars($notif['title']) ?></p>
<span class="w-2 h-2 bg-red-500 rounded-full flex-shrink-0"></span>
</div>
<p class="text-xs text-gray-600 mt-0.5">
<?= htmlspecialchars(\App\Helpers\LayoutHelper::formatLoginDropdown($loginData)) ?>
</p>
<p class="text-xs text-gray-400 mt-1">
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> mr-0.5"></i>
<?= htmlspecialchars($loginData['reason'] ?? 'Failed') ?> · <?= $notif['time_ago'] ?>
</p>
</a>
<?php elseif ($loginData && $notif['type'] === 'session_new'): ?>
<!-- Session notification with flag icon -->
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
<?php if ($loginData['country_code'] !== 'xx'): ?>
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-base rounded-sm"></span>
<?php else: ?>
<i class="fas fa-sign-in-alt text-blue-600 text-sm"></i>
<?php endif; ?>
</a>
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<p class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($notif['title']) ?></p>
<span class="w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"></span>
</div>
<p class="text-xs text-gray-600 mt-0.5">
<?= htmlspecialchars(\App\Helpers\LayoutHelper::formatLoginDropdown($loginData)) ?>
</p>
<p class="text-xs text-gray-400 mt-1">
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> mr-0.5"></i>
<?= htmlspecialchars($loginData['method'] ?? 'Login') ?> · <?= $notif['time_ago'] ?>
</p>
</a>
<?php else: ?>
<!-- Standard notification -->
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-<?= $notif['color'] ?>-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
<i class="fas fa-<?= $notif['icon'] ?> text-<?= $notif['color'] ?>-600 text-sm"></i>
</a>
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<p class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($notif['title']) ?></p>
<span class="w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"></span>
</div>
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notif['message']) ?></p>
<p class="text-xs text-gray-400 mt-1">
<?= $notif['time_ago'] ?>
<?php if ($hasDomain): ?>
<span class="text-primary ml-1"><i class="fas fa-external-link-alt text-[10px]"></i> View domain</span>
<?php endif; ?>
</p>
</a>
<?php endif; ?>
<button onclick="event.stopPropagation(); markNotifRead(<?= $notif['id'] ?>, this)"
class="w-7 h-7 flex items-center justify-center text-gray-400 hover:text-green-600 hover:bg-green-50 rounded transition-colors flex-shrink-0"
title="Mark as read">
<i class="fas fa-check text-xs"></i>
</button>
</div>
</div>
<?php endforeach; ?>
@@ -194,7 +259,7 @@
<i class="fas fa-bell w-5 text-gray-400 mr-3"></i>
Notifications
<?php if ($unreadNotifications > 0): ?>
<span class="ml-auto px-2 py-0.5 bg-orange-500 text-white text-xs font-bold rounded-full">
<span id="userDropdownNotifBadge" class="ml-auto px-2 py-0.5 bg-orange-500 text-white text-xs font-bold rounded-full">
<?= $unreadNotifications ?>
</span>
<?php endif; ?>
@@ -220,3 +285,69 @@
</div>
</div>
</nav>
<!-- Notification AJAX handler -->
<script>
function markNotifRead(notifId, btn) {
fetch('/notifications/' + notifId + '/mark-read?ajax=1', {
headers: {
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(r => {
if (!r.ok) throw new Error('Request failed');
return r.json();
})
.then(data => {
if (!data.success) return;
const newCount = data.unread_count ?? 0;
// Remove the notification item from dropdown
const item = btn.closest('.notification-item');
if (item) {
const scrollable = document.querySelector('#notificationsDropdown .max-h-96');
const isLast = scrollable && scrollable.querySelectorAll('.notification-item').length <= 1;
if (isLast && scrollable) {
scrollable.style.transition = 'opacity 0.2s';
scrollable.style.opacity = '0';
setTimeout(() => {
scrollable.innerHTML = '<div class="px-4 py-8 text-center">' +
'<i class="fas fa-bell-slash text-gray-300 text-3xl mb-2"></i>' +
'<p class="text-sm text-gray-600">No new notifications</p>' +
'<p class="text-xs text-gray-400 mt-0.5">You\'re all caught up!</p>' +
'</div>';
scrollable.style.opacity = '1';
}, 200);
} else {
item.style.transition = 'opacity 0.2s, max-height 0.3s';
item.style.opacity = '0';
item.style.maxHeight = '0';
item.style.overflow = 'hidden';
item.style.padding = '0';
item.style.margin = '0';
setTimeout(() => item.remove(), 300);
}
}
// Update all badges using server-returned count
const headerBadge = document.getElementById('dropdownHeaderBadge');
const userBadge = document.getElementById('userDropdownNotifBadge');
const bellDot = document.querySelector('[onclick="toggleNotifications()"] .absolute.top-1');
if (newCount <= 0) {
if (headerBadge) headerBadge.remove();
if (userBadge) userBadge.remove();
if (bellDot) bellDot.remove();
} else {
if (headerBadge) headerBadge.textContent = newCount + ' new';
if (userBadge) userBadge.textContent = newCount;
}
})
.catch(() => {
window.location.href = '/notifications/' + notifId + '/mark-read';
});
}
</script>

View File

@@ -56,11 +56,16 @@ $offset = $pagination['showing_from'] - 1;
<optgroup label="Domain">
<option value="domain_expiring" <?= $filterType === 'domain_expiring' ? 'selected' : '' ?>>Domain Expiring</option>
<option value="domain_expired" <?= $filterType === 'domain_expired' ? 'selected' : '' ?>>Domain Expired</option>
<option value="domain_available" <?= $filterType === 'domain_available' ? 'selected' : '' ?>>Domain Available</option>
<option value="domain_registered" <?= $filterType === 'domain_registered' ? 'selected' : '' ?>>Domain Registered</option>
<option value="domain_redemption" <?= $filterType === 'domain_redemption' ? 'selected' : '' ?>>Redemption Period</option>
<option value="domain_pending_delete" <?= $filterType === 'domain_pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
<option value="domain_updated" <?= $filterType === 'domain_updated' ? 'selected' : '' ?>>Domain Updated</option>
<option value="whois_failed" <?= $filterType === 'whois_failed' ? 'selected' : '' ?>>WHOIS Failed</option>
</optgroup>
<optgroup label="System">
<option value="session_new" <?= $filterType === 'session_new' ? 'selected' : '' ?>>New Login</option>
<option value="session_failed" <?= $filterType === 'session_failed' ? 'selected' : '' ?>>Failed Login</option>
<option value="system_welcome" <?= $filterType === 'system_welcome' ? 'selected' : '' ?>>Welcome</option>
<option value="system_upgrade" <?= $filterType === 'system_upgrade' ? 'selected' : '' ?>>System Upgrade</option>
</optgroup>
@@ -129,34 +134,178 @@ $offset = $pagination['showing_from'] - 1;
$bgClass = $notification['is_read'] ? '' : 'bg-blue-50';
$iconBgClass = "bg-{$notification['color']}-100";
$iconTextClass = "text-{$notification['color']}-600";
$hasDomain = !empty($notification['domain_id']);
$domainUrl = $hasDomain ? '/domains/' . $notification['domain_id'] : null;
$clickUrl = null;
if ($hasDomain && !$notification['is_read']) {
$clickUrl = '/notifications/' . $notification['id'] . '/mark-read?redirect=domain&domain_id=' . $notification['domain_id'];
} elseif ($hasDomain) {
$clickUrl = $domainUrl;
}
$loginData = $notification['login_data'] ?? null;
$isLogin = ($notification['type'] === 'session_new' && $loginData);
$isFailedLogin = ($notification['type'] === 'session_failed' && $loginData);
?>
<div class="px-4 py-3 hover:bg-gray-50 transition-colors <?= $bgClass ?>">
<div class="flex items-center gap-3">
<div class="flex items-start gap-3">
<!-- Icon -->
<div class="w-8 h-8 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-xs"></i>
</div>
<?php if ($isFailedLogin): ?>
<div class="w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-shield-alt text-red-600"></i>
</div>
<?php elseif ($isLogin): ?>
<div class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-sign-in-alt text-blue-600"></i>
</div>
<?php elseif ($clickUrl): ?>
<a href="<?= $clickUrl ?>" class="w-10 h-10 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-sm"></i>
</a>
<?php else: ?>
<div class="w-10 h-10 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-sm"></i>
</div>
<?php endif; ?>
<!-- Content -->
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<h3 class="text-sm font-medium text-gray-900"><?= htmlspecialchars($notification['title']) ?></h3>
<?php if ($clickUrl): ?>
<a href="<?= $clickUrl ?>" class="text-sm font-medium text-gray-900 hover:text-primary transition-colors"><?= htmlspecialchars($notification['title']) ?></a>
<?php else: ?>
<h3 class="text-sm font-medium text-gray-900"><?= htmlspecialchars($notification['title']) ?></h3>
<?php endif; ?>
<?php if (!$notification['is_read']): ?>
<span class="flex h-1.5 w-1.5">
<span class="flex h-1.5 w-1.5 relative">
<span class="animate-ping absolute inline-flex h-1.5 w-1.5 rounded-full bg-blue-400 opacity-75"></span>
<span class="relative inline-flex rounded-full h-1.5 w-1.5 bg-blue-500"></span>
</span>
<?php endif; ?>
<span class="text-xs text-gray-400 ml-auto">
<span class="text-xs text-gray-400 ml-auto flex-shrink-0">
<i class="fas fa-clock mr-1"></i>
<?= $notification['time_ago'] ?>
</span>
</div>
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notification['message']) ?></p>
<?php if ($isFailedLogin): ?>
<!-- Rich failed login details (mirrors successful login layout) -->
<div class="mt-1.5 bg-red-50 rounded-lg p-3 border border-red-200">
<div class="grid grid-cols-2 md:grid-cols-3 gap-x-4 gap-y-2 text-xs">
<!-- Location -->
<div class="flex items-center gap-1.5">
<i class="fas fa-map-marker-alt text-red-400 w-3.5 text-center"></i>
<span class="text-gray-500">Location:</span>
<span class="text-gray-800 font-medium">
<?php if (($loginData['country_code'] ?? 'xx') !== 'xx'): ?>
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-xs mr-0.5 rounded-sm"></span>
<?php endif; ?>
<?= htmlspecialchars($loginData['location'] ?? 'Unknown') ?>
</span>
</div>
<!-- IP Address -->
<div class="flex items-center gap-1.5">
<i class="fas fa-network-wired text-blue-400 w-3.5 text-center"></i>
<span class="text-gray-500">IP:</span>
<span class="text-gray-800 font-medium font-mono text-[11px]"><?= htmlspecialchars($loginData['ip'] ?? 'unknown') ?></span>
</div>
<!-- Browser -->
<div class="flex items-center gap-1.5">
<i class="fas fa-globe text-green-400 w-3.5 text-center"></i>
<span class="text-gray-500">Browser:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['browser'] ?? 'Unknown') ?></span>
</div>
<!-- Device -->
<div class="flex items-center gap-1.5">
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> text-purple-400 w-3.5 text-center"></i>
<span class="text-gray-500">Device:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['device'] ?? 'Unknown') ?></span>
</div>
<!-- OS -->
<div class="flex items-center gap-1.5">
<i class="fas fa-laptop-code text-indigo-400 w-3.5 text-center"></i>
<span class="text-gray-500">OS:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['os'] ?? 'Unknown') ?></span>
</div>
<!-- ISP -->
<div class="flex items-center gap-1.5">
<i class="fas fa-server text-amber-400 w-3.5 text-center"></i>
<span class="text-gray-500">ISP:</span>
<span class="text-gray-800 font-medium truncate"><?= htmlspecialchars($loginData['isp'] ?? 'Unknown') ?></span>
</div>
</div>
<!-- Reason (mirrors Method row) -->
<div class="mt-2 pt-2 border-t border-red-200 flex items-center gap-1.5 text-xs">
<i class="fas fa-exclamation-triangle text-gray-400 w-3.5 text-center"></i>
<span class="text-gray-500">Reason:</span>
<span class="inline-flex items-center px-1.5 py-0.5 bg-red-100 text-red-700 rounded font-medium text-[11px]"><?= htmlspecialchars($loginData['reason'] ?? 'Unknown') ?></span>
</div>
</div>
<?php elseif ($isLogin): ?>
<!-- Rich login details -->
<div class="mt-1.5 bg-gray-50 rounded-lg p-3 border border-gray-100">
<div class="grid grid-cols-2 md:grid-cols-3 gap-x-4 gap-y-2 text-xs">
<!-- Location -->
<div class="flex items-center gap-1.5">
<i class="fas fa-map-marker-alt text-red-400 w-3.5 text-center"></i>
<span class="text-gray-500">Location:</span>
<span class="text-gray-800 font-medium">
<?php if ($loginData['country_code'] !== 'xx'): ?>
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-xs mr-0.5 rounded-sm"></span>
<?php endif; ?>
<?= htmlspecialchars($loginData['location'] ?? 'Unknown') ?>
</span>
</div>
<!-- IP Address -->
<div class="flex items-center gap-1.5">
<i class="fas fa-network-wired text-blue-400 w-3.5 text-center"></i>
<span class="text-gray-500">IP:</span>
<span class="text-gray-800 font-medium font-mono text-[11px]"><?= htmlspecialchars($loginData['ip'] ?? 'unknown') ?></span>
</div>
<!-- Browser -->
<div class="flex items-center gap-1.5">
<i class="fas fa-globe text-green-400 w-3.5 text-center"></i>
<span class="text-gray-500">Browser:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['browser'] ?? 'Unknown') ?></span>
</div>
<!-- Device -->
<div class="flex items-center gap-1.5">
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> text-purple-400 w-3.5 text-center"></i>
<span class="text-gray-500">Device:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['device'] ?? 'Unknown') ?></span>
</div>
<!-- OS -->
<div class="flex items-center gap-1.5">
<i class="fas fa-laptop-code text-indigo-400 w-3.5 text-center"></i>
<span class="text-gray-500">OS:</span>
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['os'] ?? 'Unknown') ?></span>
</div>
<!-- ISP -->
<div class="flex items-center gap-1.5">
<i class="fas fa-server text-amber-400 w-3.5 text-center"></i>
<span class="text-gray-500">ISP:</span>
<span class="text-gray-800 font-medium truncate"><?= htmlspecialchars($loginData['isp'] ?? 'Unknown') ?></span>
</div>
</div>
<!-- Login method -->
<div class="mt-2 pt-2 border-t border-gray-200 flex items-center gap-1.5 text-xs">
<i class="fas fa-key text-gray-400 w-3.5 text-center"></i>
<span class="text-gray-500">Method:</span>
<span class="inline-flex items-center px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded font-medium text-[11px]"><?= htmlspecialchars($loginData['method'] ?? 'Login') ?></span>
</div>
</div>
<?php else: ?>
<!-- Standard notification message -->
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notification['message']) ?></p>
<?php if ($hasDomain && $clickUrl): ?>
<a href="<?= $clickUrl ?>" class="text-xs text-primary mt-0.5 hover:underline inline-block">
<i class="fas fa-external-link-alt text-[10px] mr-1"></i>View domain
</a>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- Actions -->
<div class="flex items-center gap-1 ml-2">
<div class="flex items-center gap-1 ml-2 flex-shrink-0">
<?php if (!$notification['is_read']): ?>
<a href="/notifications/<?= $notification['id'] ?>/mark-read" class="w-7 h-7 flex items-center justify-center text-gray-400 hover:text-green-600 hover:bg-green-50 rounded transition-colors" title="Mark as read">
<i class="fas fa-check text-xs"></i>

View File

@@ -372,6 +372,93 @@ foreach ($notificationPresets as $key => $preset) {
<div class="border-t border-gray-200 my-6"></div>
<!-- Status Change Notifications -->
<div class="mb-6">
<h4 class="text-base font-semibold text-gray-900 mb-2 flex items-center">
<i class="fas fa-exchange-alt text-primary mr-2"></i>
Status Change Notifications
</h4>
<p class="text-sm text-gray-600 mb-4">Choose which domain status changes should trigger notifications (both in-app and external channels).</p>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
<!-- Available -->
<label class="flex items-start p-3 bg-blue-50 border border-blue-200 rounded-lg cursor-pointer hover:bg-blue-100 transition-colors">
<input type="checkbox" name="notification_status_triggers[]" value="available"
<?= in_array('available', $statusTriggers) ? 'checked' : '' ?>
class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 mt-0.5">
<div class="ml-3">
<span class="text-sm font-medium text-blue-800">
<i class="fas fa-check-circle mr-1"></i> Available
</span>
<p class="text-xs text-blue-600 mt-0.5">Domain becomes available for registration</p>
</div>
</label>
<!-- Registered -->
<label class="flex items-start p-3 bg-green-50 border border-green-200 rounded-lg cursor-pointer hover:bg-green-100 transition-colors">
<input type="checkbox" name="notification_status_triggers[]" value="registered"
<?= in_array('registered', $statusTriggers) ? 'checked' : '' ?>
class="w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 mt-0.5">
<div class="ml-3">
<span class="text-sm font-medium text-green-800">
<i class="fas fa-globe mr-1"></i> Registered
</span>
<p class="text-xs text-green-600 mt-0.5">Domain becomes registered / active</p>
</div>
</label>
<!-- Expired -->
<label class="flex items-start p-3 bg-red-50 border border-red-200 rounded-lg cursor-pointer hover:bg-red-100 transition-colors">
<input type="checkbox" name="notification_status_triggers[]" value="expired"
<?= in_array('expired', $statusTriggers) ? 'checked' : '' ?>
class="w-4 h-4 text-red-600 border-gray-300 rounded focus:ring-red-500 mt-0.5">
<div class="ml-3">
<span class="text-sm font-medium text-red-800">
<i class="fas fa-times-circle mr-1"></i> Expired
</span>
<p class="text-xs text-red-600 mt-0.5">Domain status changes to expired</p>
</div>
</label>
<!-- Redemption Period -->
<label class="flex items-start p-3 bg-amber-50 border border-amber-200 rounded-lg cursor-pointer hover:bg-amber-100 transition-colors">
<input type="checkbox" name="notification_status_triggers[]" value="redemption_period"
<?= in_array('redemption_period', $statusTriggers) ? 'checked' : '' ?>
class="w-4 h-4 text-amber-600 border-gray-300 rounded focus:ring-amber-500 mt-0.5">
<div class="ml-3">
<span class="text-sm font-medium text-amber-800">
<i class="fas fa-hourglass-half mr-1"></i> Redemption Period
</span>
<p class="text-xs text-amber-600 mt-0.5">Domain enters redemption period (recovery fees apply)</p>
</div>
</label>
<!-- Pending Delete -->
<label class="flex items-start p-3 bg-rose-50 border border-rose-200 rounded-lg cursor-pointer hover:bg-rose-100 transition-colors">
<input type="checkbox" name="notification_status_triggers[]" value="pending_delete"
<?= in_array('pending_delete', $statusTriggers) ? 'checked' : '' ?>
class="w-4 h-4 text-rose-600 border-gray-300 rounded focus:ring-rose-500 mt-0.5">
<div class="ml-3">
<span class="text-sm font-medium text-rose-800">
<i class="fas fa-trash-alt mr-1"></i> Pending Delete
</span>
<p class="text-xs text-rose-600 mt-0.5">Domain is scheduled for deletion</p>
</div>
</label>
</div>
<div class="bg-gray-50 border border-gray-200 rounded-lg p-3 mt-3">
<p class="text-xs text-gray-600">
<i class="fas fa-info-circle text-gray-400 mr-1"></i>
<strong>Note:</strong> These notifications are triggered when a domain's status changes during a WHOIS check.
Redemption Period and Pending Delete detection depends on the TLD registry reporting EPP statuses.
Most gTLDs (.com, .net, .org) support this, but some ccTLDs may not.
</p>
</div>
</div>
<div class="border-t border-gray-200 my-6"></div>
<!-- Check Interval -->
<div class="mb-6">
<h4 class="text-base font-semibold text-gray-900 mb-4 flex items-center">

View File

@@ -72,7 +72,10 @@ $currentFilters = $filters ?? ['search' => '', 'status' => '', 'registrar' => ''
<option value="">All Statuses</option>
<option value="active" <?= $currentFilters['status'] === 'active' ? 'selected' : '' ?>>Active</option>
<option value="expiring_soon" <?= $currentFilters['status'] === 'expiring_soon' ? 'selected' : '' ?>>Expiring Soon</option>
<option value="expired" <?= $currentFilters['status'] === 'expired' ? 'selected' : '' ?>>Expired</option>
<option value="available" <?= $currentFilters['status'] === 'available' ? 'selected' : '' ?>>Available</option>
<option value="redemption_period" <?= $currentFilters['status'] === 'redemption_period' ? 'selected' : '' ?>>Redemption Period</option>
<option value="pending_delete" <?= $currentFilters['status'] === 'pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
<option value="error" <?= $currentFilters['status'] === 'error' ? 'selected' : '' ?>>Error</option>
<option value="inactive" <?= $currentFilters['status'] === 'inactive' ? 'selected' : '' ?>>Inactive</option>
</select>

View File

@@ -6,126 +6,268 @@ $pageIcon = 'fas fa-user-edit';
ob_start();
?>
<form method="POST" action="/users/update" class="max-w-2xl">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= $user['id'] ?>">
<div class="max-w-3xl mx-auto">
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
<h3 class="text-lg font-semibold text-gray-900">User Information</h3>
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-semibold text-gray-900 flex items-center">
<i class="fas fa-user-edit text-gray-400 mr-2 text-sm"></i>
User Information
</h2>
</div>
<div class="p-6 space-y-4">
<!-- Full Name -->
<div>
<label for="full_name" class="block text-sm font-medium text-gray-700 mb-2">
Full Name <span class="text-red-500">*</span>
</label>
<input type="text" id="full_name" name="full_name" required
value="<?= htmlspecialchars($user['full_name'] ?? '') ?>"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
</div>
<div class="p-6">
<form method="POST" action="/users/update" class="space-y-5">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= $user['id'] ?>">
<!-- Username (Read-only) -->
<div>
<label for="username" class="block text-sm font-medium text-gray-700 mb-2">
Username
</label>
<input type="text" id="username" value="<?= htmlspecialchars($user['username']) ?>" readonly
class="w-full px-3 py-2 border border-gray-300 rounded-lg bg-gray-50 text-gray-500 cursor-not-allowed">
<p class="text-xs text-gray-500 mt-1">Username cannot be changed</p>
</div>
<!-- Name & Username Row -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<!-- Full Name -->
<div>
<label for="full_name" class="block text-sm font-medium text-gray-700 mb-1.5">
Full Name <span class="text-red-500">*</span>
</label>
<input type="text"
id="full_name"
name="full_name"
required
autofocus
value="<?= htmlspecialchars($user['full_name'] ?? '') ?>"
class="w-full px-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
placeholder="John Doe">
<p class="mt-1.5 text-xs text-gray-500">
The user's display name
</p>
</div>
<!-- Email -->
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
Email Address <span class="text-red-500">*</span>
</label>
<input type="email" id="email" name="email" required
value="<?= htmlspecialchars($user['email']) ?>"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
</div>
<!-- Username (Read-only) -->
<div>
<label for="username" class="block text-sm font-medium text-gray-700 mb-1.5">
Username
</label>
<div class="relative">
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
<i class="fas fa-at text-sm"></i>
</span>
<input type="text"
id="username"
value="<?= htmlspecialchars($user['username']) ?>"
readonly
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg bg-gray-50 text-gray-500 cursor-not-allowed text-sm">
</div>
<p class="mt-1.5 text-xs text-gray-500">
Username cannot be changed
</p>
</div>
</div>
<!-- Role -->
<div>
<label for="role" class="block text-sm font-medium text-gray-700 mb-2">
Role <span class="text-red-500">*</span>
</label>
<select id="role" name="role" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
<option value="user" <?= $user['role'] === 'user' ? 'selected' : '' ?>>User</option>
<option value="admin" <?= $user['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
</select>
</div>
<!-- Email & Role Row -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<!-- Email -->
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-1.5">
Email Address <span class="text-red-500">*</span>
</label>
<div class="relative">
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
<i class="fas fa-envelope text-sm"></i>
</span>
<input type="email"
id="email"
name="email"
required
value="<?= htmlspecialchars($user['email']) ?>"
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
placeholder="john@example.com">
</div>
<p class="mt-1.5 text-xs text-gray-500">
Used for login and notifications
</p>
</div>
<!-- Status -->
<div class="flex items-start">
<div class="flex items-center h-5">
<!-- Role -->
<div>
<label for="role" class="block text-sm font-medium text-gray-700 mb-1.5">
Role <span class="text-red-500">*</span>
</label>
<div class="relative">
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
<i class="fas fa-shield-alt text-sm"></i>
</span>
<select id="role"
name="role"
required
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm appearance-none bg-white">
<option value="user" <?= $user['role'] === 'user' ? 'selected' : '' ?>>User</option>
<option value="admin" <?= $user['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
</select>
<span class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none text-gray-400">
<i class="fas fa-chevron-down text-xs"></i>
</span>
</div>
<p class="mt-1.5 text-xs text-gray-500">
Admins have full system access
</p>
</div>
</div>
<!-- Status -->
<div class="flex items-center gap-3 bg-gray-50 border border-gray-200 rounded-lg px-4 py-3">
<input type="checkbox" id="is_active" name="is_active" value="1"
<?= $user['is_active'] ? 'checked' : '' ?>
class="w-4 h-4 text-primary border-gray-300 rounded focus:ring-primary">
</div>
<div class="ml-3">
<label for="is_active" class="text-sm font-medium text-gray-700">
Active
</label>
<p class="text-xs text-gray-500">Inactive users cannot log in</p>
</div>
</div>
<!-- Password (Optional) -->
<div class="border-t border-gray-200 pt-4 mt-4">
<h4 class="text-sm font-semibold text-gray-900 mb-3">Change Password (Optional)</h4>
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">
New Password
</label>
<input type="password" id="password" name="password" minlength="8"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
<p class="text-xs text-gray-500 mt-1">Leave blank to keep current password. Minimum 8 characters if changing.</p>
</div>
</div>
<!-- Account Info -->
<div class="bg-gray-50 border border-gray-200 rounded-lg p-3 mt-4">
<div class="grid grid-cols-2 gap-3 text-xs">
<div>
<span class="text-gray-600">Email Verified:</span>
<span class="font-semibold <?= $user['email_verified'] ? 'text-green-600' : 'text-red-600' ?>">
<?= $user['email_verified'] ? 'Yes' : 'No' ?>
</span>
</div>
<div>
<span class="text-gray-600">Member Since:</span>
<span class="font-semibold text-gray-900">
<?= date('M d, Y', strtotime($user['created_at'])) ?>
</span>
</div>
<div>
<span class="text-gray-600">Last Login:</span>
<span class="font-semibold text-gray-900">
<?= $user['last_login'] ? date('M d, Y H:i', strtotime($user['last_login'])) : 'Never' ?>
</span>
<label for="is_active" class="text-sm font-medium text-gray-700">
Active Account
</label>
<p class="text-xs text-gray-500">Inactive users cannot log in to the system</p>
</div>
</div>
</div>
</div>
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50 flex items-center justify-between">
<a href="/users" class="text-gray-600 hover:text-gray-800 text-sm font-medium">
<i class="fas fa-arrow-left mr-1"></i> Cancel
</a>
<button type="submit" class="inline-flex items-center px-4 py-2.5 bg-primary text-white text-sm rounded-lg hover:bg-primary-dark transition-colors font-medium">
<i class="fas fa-save mr-2"></i>
Update User
</button>
<!-- Password Section -->
<div class="border-t border-gray-200 pt-5 mt-5">
<h3 class="text-sm font-semibold text-gray-900 mb-4 flex items-center">
<i class="fas fa-lock text-gray-400 mr-2"></i>
Change Password
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<!-- New Password -->
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-1.5">
New Password
</label>
<div class="relative">
<input type="password"
id="password"
name="password"
minlength="8"
class="w-full px-3 py-2.5 pr-10 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
placeholder="••••••••">
<button type="button"
onclick="togglePassword('password')"
class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
<i class="fas fa-eye text-sm" id="password-toggle-icon"></i>
</button>
</div>
<p class="mt-1.5 text-xs text-gray-500">
Leave blank to keep current password
</p>
</div>
<!-- Confirm Password -->
<div>
<label for="password_confirm" class="block text-sm font-medium text-gray-700 mb-1.5">
Confirm Password
</label>
<div class="relative">
<input type="password"
id="password_confirm"
name="password_confirm"
minlength="8"
class="w-full px-3 py-2.5 pr-10 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
placeholder="••••••••">
<button type="button"
onclick="togglePassword('password_confirm')"
class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
<i class="fas fa-eye text-sm" id="password_confirm-toggle-icon"></i>
</button>
</div>
<p class="mt-1.5 text-xs text-gray-500">
Re-enter the new password to confirm
</p>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="flex flex-col sm:flex-row gap-3 pt-3">
<button type="submit"
class="inline-flex items-center justify-center px-5 py-2.5 bg-primary hover:bg-primary-dark text-white rounded-lg font-medium transition-colors text-sm">
<i class="fas fa-save mr-2"></i>
Update User
</button>
<a href="/users"
class="inline-flex items-center justify-center px-5 py-2.5 border border-gray-300 text-gray-700 rounded-lg font-medium hover:bg-gray-50 transition-colors text-sm">
<i class="fas fa-times mr-2"></i>
Cancel
</a>
</div>
</form>
</div>
</div>
</form>
<!-- Account Info Section -->
<div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<div class="w-10 h-10 bg-blue-500 rounded-lg flex items-center justify-center">
<i class="fas fa-info-circle text-white"></i>
</div>
</div>
<div class="ml-3">
<h3 class="text-sm font-semibold text-gray-900 mb-1">Account Details</h3>
<ul class="text-xs text-gray-600 space-y-1">
<li class="flex items-center">
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
<span class="ml-2">Email Verified:
<span class="font-semibold <?= $user['email_verified'] ? 'text-green-600' : 'text-red-600' ?>">
<?= $user['email_verified'] ? 'Yes' : 'No' ?>
</span>
</span>
</li>
<li class="flex items-center">
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
<span class="ml-2">Member Since:
<span class="font-semibold text-gray-900"><?= date('M d, Y', strtotime($user['created_at'])) ?></span>
</span>
</li>
<li class="flex items-center">
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
<span class="ml-2">Last Login:
<span class="font-semibold text-gray-900"><?= $user['last_login'] ? date('M d, Y H:i', strtotime($user['last_login'])) : 'Never' ?></span>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<script>
function togglePassword(fieldId) {
const field = document.getElementById(fieldId);
const icon = document.getElementById(fieldId + '-toggle-icon');
if (field.type === 'password') {
field.type = 'text';
icon.classList.remove('fa-eye');
icon.classList.add('fa-eye-slash');
} else {
field.type = 'password';
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
}
}
// Password confirmation validation
document.getElementById('password_confirm').addEventListener('input', function() {
const password = document.getElementById('password').value;
const confirm = this.value;
if (confirm && password !== confirm) {
this.setCustomValidity('Passwords do not match');
this.classList.add('border-red-300');
this.classList.remove('border-gray-300');
} else {
this.setCustomValidity('');
this.classList.remove('border-red-300');
this.classList.add('border-gray-300');
}
});
</script>
<?php
$content = ob_get_clean();
require __DIR__ . '/../layout/base.php';
?>

View File

@@ -230,7 +230,18 @@ $pagination = $pagination ?? [
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900"><?= htmlspecialchars($user['username']) ?></div>
<div class="flex items-center gap-2">
<span class="text-sm text-gray-900"><?= htmlspecialchars($user['username']) ?></span>
<?php if (!empty($user['two_factor_enabled'])): ?>
<span class="inline-flex items-center px-1.5 py-0.5 bg-green-100 text-green-700 rounded text-[10px] font-semibold border border-green-200" title="Two-factor authentication enabled">
<i class="fas fa-shield-alt mr-0.5"></i>2FA
</span>
<?php else: ?>
<span class="inline-flex items-center px-1.5 py-0.5 bg-gray-100 text-gray-400 rounded text-[10px] font-medium border border-gray-200" title="Two-factor authentication not enabled">
<i class="fas fa-shield-alt mr-0.5"></i>No 2FA
</span>
<?php endif; ?>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold border