Compare commits
7 Commits
dcaab71244
...
3e007c07f4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e007c07f4 | |||
|
|
cc044aca17 | ||
|
|
12c9e75743 | ||
|
|
4e73ccb60b | ||
|
|
c404331918 | ||
|
|
ad6fb4082d | ||
|
|
7cbe4e4b7b |
File diff suppressed because one or more lines are too long
@@ -1,5 +1,4 @@
|
|||||||
// src/app/admin/devices/page.tsx
|
// src/app/admin/devices/page.tsx
|
||||||
import { cookies } from 'next/headers';
|
|
||||||
import { requireAuthOrRedirect } from '@/lib/authServer';
|
import { requireAuthOrRedirect } from '@/lib/authServer';
|
||||||
import axiosServer from '@/lib/axiosServer';
|
import axiosServer from '@/lib/axiosServer';
|
||||||
import DeviceTableSection from '@/components/admin/DeviceTableSection';
|
import DeviceTableSection from '@/components/admin/DeviceTableSection';
|
||||||
@@ -16,17 +15,19 @@ interface DeviceDTO {
|
|||||||
|
|
||||||
export default async function DeviceManagementPage() {
|
export default async function DeviceManagementPage() {
|
||||||
const user = await requireAuthOrRedirect();
|
const user = await requireAuthOrRedirect();
|
||||||
const cookieStore = cookies();
|
|
||||||
// @ts-expect-error cookies() isn't really async
|
|
||||||
const token = cookieStore.get('authToken')?.value;
|
|
||||||
|
|
||||||
const res = await axiosServer.get('/admin/devices', {
|
try {
|
||||||
headers: {
|
const res = await axiosServer.get('/admin/devices', {
|
||||||
Authorization: `Bearer ${user.token}`,
|
headers: {
|
||||||
},
|
Authorization: `Bearer ${user.token}`,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const devices: DeviceDTO[] = res.data;
|
const devices: DeviceDTO[] = res.data;
|
||||||
|
|
||||||
return <DeviceTableSection initialDevices={devices} />;
|
return <DeviceTableSection initialDevices={devices} />;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to fetch devices:', error);
|
||||||
|
throw new Error(`Failed to load devices: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// src/app/admin/users/page.tsx
|
// src/app/admin/users/page.tsx
|
||||||
import { cookies } from 'next/headers';
|
|
||||||
import { requireAuthOrRedirect } from '@/lib/authServer';
|
import { requireAuthOrRedirect } from '@/lib/authServer';
|
||||||
import axiosServer from '@/lib/axiosServer';
|
import axiosServer from '@/lib/axiosServer';
|
||||||
import UserTableSection from '@/components/admin/UserTableSection';
|
import UserTableSection from '@/components/admin/UserTableSection';
|
||||||
@@ -19,18 +18,19 @@ interface UserDTO {
|
|||||||
|
|
||||||
export default async function UserManagementPage() {
|
export default async function UserManagementPage() {
|
||||||
const user = await requireAuthOrRedirect();
|
const user = await requireAuthOrRedirect();
|
||||||
const cookieStore = cookies();
|
|
||||||
// @ts-expect-error - cookies() is not actually async, type is misleading
|
|
||||||
const token = cookieStore.get('authToken')?.value;
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await axiosServer.get('/admin/users', {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${user.token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const res = await axiosServer.get('/admin/users', {
|
const users: UserDTO[] = res.data;
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${user.token}`, // token is guaranteed to exist
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const users: UserDTO[] = res.data;
|
return <UserTableSection initialUsers={users} />;
|
||||||
|
} catch (error) {
|
||||||
return <UserTableSection initialUsers={users} />;
|
console.error('Failed to fetch users:', error);
|
||||||
|
throw new Error(`Failed to load users: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,6 +225,21 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const runCveVerification = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
await api.post('/admin/scripts/verify-cve-count');
|
||||||
|
setCveVisible(true);
|
||||||
|
setToastMessage('🔍 CVE verification started - check logs for comparison results');
|
||||||
|
setToastOpen(true);
|
||||||
|
} catch (err: any) {
|
||||||
|
setToastMessage("❌ Failed to start CVE verification: " + (err?.response?.data || err.message));
|
||||||
|
setToastOpen(true);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const openDialog = async () => {
|
const openDialog = async () => {
|
||||||
await fetchClients();
|
await fetchClients();
|
||||||
setDialogOpen(true);
|
setDialogOpen(true);
|
||||||
@@ -269,6 +284,16 @@
|
|||||||
{loading ? 'Starting Backfill...' : 'Backfill All CVEs (2002-Present)'}
|
{loading ? 'Starting Backfill...' : 'Backfill All CVEs (2002-Present)'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="info"
|
||||||
|
onClick={runCveVerification}
|
||||||
|
disabled={loading}
|
||||||
|
sx={{ mt: 2 }}
|
||||||
|
>
|
||||||
|
{loading ? 'Verifying...' : 'Verify CVE Count (GitHub API)'}
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={runVulnCacheRefresh}
|
onClick={runVulnCacheRefresh}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
// src/lib/axiosServer.ts
|
// src/lib/axiosServer.ts
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import https from 'https';
|
||||||
|
|
||||||
const axiosServer = axios.create({
|
const axiosServer = axios.create({
|
||||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/api',
|
baseURL: process.env.API_BASE_URL || 'http://localhost:8080/api',
|
||||||
|
httpsAgent: new https.Agent({
|
||||||
|
rejectUnauthorized: false, // Accept self-signed certificates
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default axiosServer;
|
export default axiosServer;
|
||||||
|
|||||||
Reference in New Issue
Block a user