mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-03-10 04:51:47 +00:00
chore: atualizações de dependências, lint fixes e ajustes menores
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import { and, desc, eq, isNull } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
import { tokensApi } from "@/db/schema";
|
||||
@@ -15,7 +15,7 @@ export async function GET() {
|
||||
}
|
||||
|
||||
// Buscar tokens ativos do usuário
|
||||
const tokens = await db
|
||||
const activeTokens = await db
|
||||
.select({
|
||||
id: tokensApi.id,
|
||||
name: tokensApi.name,
|
||||
@@ -26,14 +26,11 @@ export async function GET() {
|
||||
createdAt: tokensApi.createdAt,
|
||||
})
|
||||
.from(tokensApi)
|
||||
.where(eq(tokensApi.userId, session.user.id))
|
||||
.where(
|
||||
and(eq(tokensApi.userId, session.user.id), isNull(tokensApi.revokedAt)),
|
||||
)
|
||||
.orderBy(desc(tokensApi.createdAt));
|
||||
|
||||
// Separar tokens ativos e revogados
|
||||
const activeTokens = tokens.filter(
|
||||
(t) => !t.expiresAt || new Date(t.expiresAt) > new Date(),
|
||||
);
|
||||
|
||||
return NextResponse.json({ tokens: activeTokens });
|
||||
} catch (error) {
|
||||
console.error("[API] Error listing device tokens:", error);
|
||||
|
||||
Reference in New Issue
Block a user