mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
4b90b35748
Extend multi-download-client support to include Transmission and NZBGet and introduce per-client custom download paths. Adds protocol mapping and new client types, Transmission/NZBGet integration services, API CRUD and validation changes, UI components/modal updates and live path previews, and manager routing by protocol. Includes DB migrations (download_path on download_history, interactive_search_access on users), schema updates, and related processor/service fixes and tests to ensure backward compatibility and proper path resolution.
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
/**
|
|
* Component: Admin Users API
|
|
* Documentation: documentation/admin-dashboard.md
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { requireAuth, requireAdmin, AuthenticatedRequest } from '@/lib/middleware/auth';
|
|
import { prisma } from '@/lib/db';
|
|
import { RMABLogger } from '@/lib/utils/logger';
|
|
|
|
const logger = RMABLogger.create('API.Admin.Users');
|
|
|
|
export async function GET(request: NextRequest) {
|
|
return requireAuth(request, async (req: AuthenticatedRequest) => {
|
|
return requireAdmin(req, async () => {
|
|
try {
|
|
const users = await prisma.user.findMany({
|
|
where: {
|
|
deletedAt: null, // Exclude soft-deleted users
|
|
},
|
|
select: {
|
|
id: true,
|
|
plexId: true,
|
|
plexUsername: true,
|
|
plexEmail: true,
|
|
role: true,
|
|
isSetupAdmin: true,
|
|
authProvider: true,
|
|
avatarUrl: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
lastLoginAt: true,
|
|
autoApproveRequests: true,
|
|
interactiveSearchAccess: true,
|
|
_count: {
|
|
select: {
|
|
requests: true,
|
|
},
|
|
},
|
|
},
|
|
orderBy: {
|
|
createdAt: 'desc',
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({ users });
|
|
} catch (error) {
|
|
logger.error('Failed to fetch users', { error: error instanceof Error ? error.message : String(error) });
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch users' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
});
|
|
});
|
|
}
|