KI-AGENT: Persistente App-Sessions mit Refresh-Tokens ergänzen
This commit is contained in:
20
backend/db/schema/auth_refresh_tokens.ts
Normal file
20
backend/db/schema/auth_refresh_tokens.ts
Normal 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
|
||||
@@ -7,6 +7,7 @@ export * from "./auth_roles"
|
||||
export * from "./auth_tenant_users"
|
||||
export * from "./auth_user_roles"
|
||||
export * from "./auth_users"
|
||||
export * from "./auth_refresh_tokens"
|
||||
export * from "./bankaccounts"
|
||||
export * from "./bankrequisitions"
|
||||
export * from "./bankstatements"
|
||||
|
||||
Reference in New Issue
Block a user