Refresh Token 구현 변경

This commit is contained in:
static
2024-12-28 15:44:30 +09:00
parent 796e4a7831
commit 1d0c309878
11 changed files with 233 additions and 79 deletions

View File

@@ -1,2 +1,3 @@
export * from "./client";
export * from "./token";
export * from "./user";

View File

@@ -0,0 +1,18 @@
import { sqliteTable, text, integer, unique } from "drizzle-orm/sqlite-core";
import { client } from "./client";
import { user } from "./user";
export const refreshToken = sqliteTable(
"refresh_token",
{
id: text("id").primaryKey(),
userId: integer("user_id")
.notNull()
.references(() => user.id),
clientId: integer("client_id").references(() => client.id),
expiresAt: integer("expires_at").notNull(), // Only used for cleanup
},
(t) => ({
unq: unique().on(t.userId, t.clientId),
}),
);

View File

@@ -5,9 +5,3 @@ export const user = sqliteTable("user", {
email: text("email").notNull().unique(),
password: text("password").notNull(),
});
export const revokedToken = sqliteTable("revoked_token", {
id: integer("id").primaryKey(),
token: text("token").notNull().unique(),
revokedAt: integer("revoked_at").notNull(),
});