feat(auth): add Discord OAuth sign-in and user timezones
Add persistent user and session storage, protected profile requests, and React sign-in controls. Capture and preserve each user's timezone, and load development and production configuration before migrations and server startup.
This commit is contained in:
@@ -1,2 +1,22 @@
|
||||
// Define application tables here with drizzle-orm/sqlite-core.
|
||||
export {};
|
||||
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const users = sqliteTable("users", {
|
||||
id: text("id").primaryKey(),
|
||||
discordId: text("discord_id").notNull().unique(),
|
||||
username: text("username").notNull(),
|
||||
globalName: text("global_name"),
|
||||
avatarHash: text("avatar_hash"),
|
||||
timezone: text("timezone").notNull().default("UTC"),
|
||||
createdAt: integer("created_at").notNull(),
|
||||
updatedAt: integer("updated_at").notNull(),
|
||||
});
|
||||
|
||||
export const sessions = sqliteTable("sessions", {
|
||||
tokenHash: text("token_hash").primaryKey(),
|
||||
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
||||
createdAt: integer("created_at").notNull(),
|
||||
expiresAt: integer("expires_at").notNull(),
|
||||
}, table => [
|
||||
index("sessions_user_id_idx").on(table.userId),
|
||||
index("sessions_expires_at_idx").on(table.expiresAt),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user