KI-AGENT: Persistente App-Sessions mit Refresh-Tokens ergänzen

This commit is contained in:
2026-07-20 22:01:08 +02:00
parent d8273e794d
commit 657a4f9e85
11 changed files with 405 additions and 60 deletions

View File

@@ -0,0 +1,20 @@
import { pgTable, text, timestamp, uuid, bigint } from "drizzle-orm/pg-core"
import { authUsers } from "./auth_users"
import { tenants } from "./tenants"
export const authRefreshTokens = pgTable("auth_refresh_tokens", {
id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id")
.notNull()
.references(() => authUsers.id, { onDelete: "cascade", onUpdate: "cascade" }),
tenantId: bigint("tenant_id", { mode: "number" })
.references(() => tenants.id, { onDelete: "set null", onUpdate: "cascade" }),
tokenHash: text("token_hash").notNull().unique(),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
revokedAt: timestamp("revoked_at", { withTimezone: true }),
})
export type AuthRefreshToken = typeof authRefreshTokens.$inferSelect
export type NewAuthRefreshToken = typeof authRefreshTokens.$inferInsert