feat: enhance mobile compatibility and debugging across authentication and system metrics
All checks were successful
Build And Push Image / docker (push) Successful in 3m18s
All checks were successful
Build And Push Image / docker (push) Successful in 3m18s
This commit is contained in:
@@ -285,12 +285,21 @@ export default defineEventHandler(async (event) => {
|
||||
const cookieParts = cookieString.split(';')[0].split('=');
|
||||
const sessionId = cookieParts[1];
|
||||
|
||||
// Set the cookie using Nuxt's setCookie helper
|
||||
// Set the cookie using Nuxt's setCookie helper with mobile-compatible settings
|
||||
const maxAge = !!rememberMe ? 60 * 60 * 24 * 30 : 60 * 60 * 24 * 7; // 30 days vs 7 days
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
console.log('🍪 Setting cookie with mobile-friendly settings:', {
|
||||
secure: isProduction,
|
||||
sameSite: 'lax',
|
||||
maxAge,
|
||||
rememberMe: !!rememberMe
|
||||
});
|
||||
|
||||
setCookie(event, 'monacousa-session', sessionId, {
|
||||
httpOnly: true,
|
||||
secure: true,
|
||||
sameSite: 'none',
|
||||
secure: isProduction, // Only secure in production
|
||||
sameSite: 'lax', // Changed from 'none' for mobile compatibility
|
||||
maxAge,
|
||||
path: '/',
|
||||
});
|
||||
|
||||
@@ -22,6 +22,14 @@ export default defineEventHandler(async (event) => {
|
||||
console.log('✅ Valid session found for user:', session.user.email);
|
||||
console.log('🎯 User tier:', session.user.tier);
|
||||
console.log('📋 User groups:', session.user.groups);
|
||||
console.log('👤 User data:', {
|
||||
id: session.user.id,
|
||||
email: session.user.email,
|
||||
name: session.user.name,
|
||||
firstName: session.user.firstName,
|
||||
lastName: session.user.lastName,
|
||||
username: session.user.username
|
||||
});
|
||||
|
||||
return {
|
||||
authenticated: true,
|
||||
|
||||
@@ -36,14 +36,15 @@ export async function getSystemMetrics(): Promise<SystemMetrics> {
|
||||
|
||||
// Return cached data if still valid
|
||||
if (metricsCache && (now - lastCacheTime) < CACHE_DURATION) {
|
||||
console.log('📊 Returning cached system metrics');
|
||||
return metricsCache;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('🔄 Fetching fresh system metrics...');
|
||||
|
||||
// Get all metrics in parallel for better performance
|
||||
const [cpuData, memData, fsData, currentLoad, processData, uptimeData] = await Promise.all([
|
||||
// Get all metrics in parallel with individual error handling
|
||||
const results = await Promise.allSettled([
|
||||
si.cpu(),
|
||||
si.mem(),
|
||||
si.fsSize(),
|
||||
@@ -52,8 +53,24 @@ export async function getSystemMetrics(): Promise<SystemMetrics> {
|
||||
si.time()
|
||||
]);
|
||||
|
||||
// Extract data with fallbacks for failed promises
|
||||
const cpuData = results[0].status === 'fulfilled' ? results[0].value : { cores: 0, brand: 'Unknown' };
|
||||
const memData = results[1].status === 'fulfilled' ? results[1].value : { total: 0, used: 0, free: 0 };
|
||||
const fsData = results[2].status === 'fulfilled' ? results[2].value : [];
|
||||
const currentLoad = results[3].status === 'fulfilled' ? results[3].value : { currentLoad: 0 };
|
||||
const processData = results[4].status === 'fulfilled' ? results[4].value : { all: 0, running: 0, sleeping: 0 };
|
||||
const uptimeData = results[5].status === 'fulfilled' ? results[5].value : { uptime: 0 };
|
||||
|
||||
// Log any failures
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === 'rejected') {
|
||||
const names = ['CPU', 'Memory', 'Filesystem', 'CPU Load', 'Processes', 'Uptime'];
|
||||
console.warn(`⚠️ ${names[index]} data failed:`, result.reason?.message || result.reason);
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate disk totals across all mounted filesystems
|
||||
const diskTotals = fsData.reduce((acc, fs) => {
|
||||
const diskTotals = (fsData as any[]).reduce((acc: { total: number; used: number }, fs: any) => {
|
||||
// Skip special filesystems and focus on main storage
|
||||
if (fs.type && !['tmpfs', 'devtmpfs', 'proc', 'sysfs'].includes(fs.type.toLowerCase())) {
|
||||
acc.total += fs.size || 0;
|
||||
|
||||
Reference in New Issue
Block a user