forked from git.gladyson/openmonetis
refactor: atualizar imports para os novos nomes de tabelas
- Atualizar imports em todos os arquivos que usavam os nomes antigos - Corrigir referências para preferenciasUsuario, insightsSalvos, tokensApi, preLancamentos, antecipacoesParcelas, compartilhamentosPagador
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
/**
|
||||
* DELETE /api/auth/device/tokens/[tokenId]
|
||||
*
|
||||
* Revoga um token de API específico.
|
||||
* Requer sessão web autenticada.
|
||||
*/
|
||||
|
||||
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
import { apiTokens } from "@/db/schema";
|
||||
import { tokensApi } from "@/db/schema";
|
||||
import { auth } from "@/lib/auth/config";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
@@ -28,10 +23,10 @@ export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
}
|
||||
|
||||
// Verificar se token pertence ao usuário
|
||||
const token = await db.query.apiTokens.findFirst({
|
||||
const token = await db.query.tokensApi.findFirst({
|
||||
where: and(
|
||||
eq(apiTokens.id, tokenId),
|
||||
eq(apiTokens.userId, session.user.id),
|
||||
eq(tokensApi.id, tokenId),
|
||||
eq(tokensApi.userId, session.user.id),
|
||||
),
|
||||
});
|
||||
|
||||
@@ -44,9 +39,9 @@ export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
|
||||
// Revogar token (soft delete)
|
||||
await db
|
||||
.update(apiTokens)
|
||||
.update(tokensApi)
|
||||
.set({ revokedAt: new Date() })
|
||||
.where(eq(apiTokens.id, tokenId));
|
||||
.where(eq(tokensApi.id, tokenId));
|
||||
|
||||
return NextResponse.json({
|
||||
message: "Token revogado com sucesso",
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
/**
|
||||
* GET /api/auth/device/tokens
|
||||
*
|
||||
* Lista todos os tokens de API do usuário.
|
||||
* Requer sessão web autenticada.
|
||||
*/
|
||||
|
||||
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
import { apiTokens } from "@/db/schema";
|
||||
import { tokensApi } from "@/db/schema";
|
||||
import { auth } from "@/lib/auth/config";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
@@ -24,17 +19,17 @@ export async function GET() {
|
||||
// Buscar tokens ativos do usuário
|
||||
const tokens = await db
|
||||
.select({
|
||||
id: apiTokens.id,
|
||||
name: apiTokens.name,
|
||||
tokenPrefix: apiTokens.tokenPrefix,
|
||||
lastUsedAt: apiTokens.lastUsedAt,
|
||||
lastUsedIp: apiTokens.lastUsedIp,
|
||||
expiresAt: apiTokens.expiresAt,
|
||||
createdAt: apiTokens.createdAt,
|
||||
id: tokensApi.id,
|
||||
name: tokensApi.name,
|
||||
tokenPrefix: tokensApi.tokenPrefix,
|
||||
lastUsedAt: tokensApi.lastUsedAt,
|
||||
lastUsedIp: tokensApi.lastUsedIp,
|
||||
expiresAt: tokensApi.expiresAt,
|
||||
createdAt: tokensApi.createdAt,
|
||||
})
|
||||
.from(apiTokens)
|
||||
.where(eq(apiTokens.userId, session.user.id))
|
||||
.orderBy(desc(apiTokens.createdAt));
|
||||
.from(tokensApi)
|
||||
.where(eq(tokensApi.userId, session.user.id))
|
||||
.orderBy(desc(tokensApi.createdAt));
|
||||
|
||||
// Separar tokens ativos e revogados
|
||||
const activeTokens = tokens.filter(
|
||||
|
||||
Reference in New Issue
Block a user