fix: adjust admin user routes and sidebar deps
This commit is contained in:
parent
4951e82834
commit
076c0df7f9
3 changed files with 10 additions and 7 deletions
|
|
@ -17,14 +17,15 @@ function generatePassword(length = 12) {
|
|||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
export async function POST(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const session = await assertAdminSession()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
}
|
||||
|
||||
const user = await prisma.authUser.findUnique({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
select: { id: true, role: true },
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@ function mapToUserRole(role: RoleOption) {
|
|||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export async function GET(_: Request, { params }: { params: { id: string } }) {
|
||||
export async function GET(_: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const session = await assertAdminSession()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
}
|
||||
|
||||
const user = await prisma.authUser.findUnique({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
|
|
@ -70,7 +71,8 @@ export async function GET(_: Request, { params }: { params: { id: string } }) {
|
|||
})
|
||||
}
|
||||
|
||||
export async function PATCH(request: Request, { params }: { params: { id: string } }) {
|
||||
export async function PATCH(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const session = await assertAdminSession()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
|
|
@ -88,7 +90,7 @@ export async function PATCH(request: Request, { params }: { params: { id: string
|
|||
return NextResponse.json({ error: "Payload inválido" }, { status: 400 })
|
||||
}
|
||||
|
||||
const user = await prisma.authUser.findUnique({ where: { id: params.id } })
|
||||
const user = await prisma.authUser.findUnique({ where: { id } })
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: "Usuário não encontrado" }, { status: 404 })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue