check for stale users on signup

This commit is contained in:
Milo Schwartz 2024-10-07 23:31:23 -04:00
parent 3a52615e3e
commit 6fb569e2cd
No known key found for this signature in database
4 changed files with 55 additions and 7 deletions

View file

@ -81,6 +81,7 @@ export const users = sqliteTable("user", {
emailVerified: integer("emailVerified", { mode: "boolean" })
.notNull()
.default(false),
dateCreated: text("dateCreated").notNull(),
});
export const twoFactorBackupCodes = sqliteTable("twoFactorBackupCodes", {
@ -107,7 +108,9 @@ export const userOrgs = sqliteTable("userOrgs", {
orgId: integer("orgId")
.notNull()
.references(() => orgs.orgId),
roleId: integer("roleId").notNull().references(() => roles.roleId),
roleId: integer("roleId")
.notNull()
.references(() => roles.roleId),
});
export const emailVerificationCodes = sqliteTable("emailVerificationCodes", {
@ -137,7 +140,9 @@ export const actions = sqliteTable("actions", {
export const roles = sqliteTable("roles", {
roleId: integer("roleId").primaryKey({ autoIncrement: true }),
orgId: integer("orgId").references(() => orgs.orgId, { onDelete: "cascade" }),
orgId: integer("orgId").references(() => orgs.orgId, {
onDelete: "cascade",
}),
name: text("name").notNull(),
description: text("description"),
});
@ -204,7 +209,9 @@ export const userResources = sqliteTable("userResources", {
export const limitsTable = sqliteTable("limits", {
limitId: integer("limitId").primaryKey({ autoIncrement: true }),
orgId: integer("orgId").references(() => orgs.orgId, { onDelete: "cascade" }),
orgId: integer("orgId").references(() => orgs.orgId, {
onDelete: "cascade",
}),
name: text("name").notNull(),
value: integer("value").notNull(),
description: text("description"),
@ -232,4 +239,4 @@ export type RoleSite = InferSelectModel<typeof roleSites>;
export type UserSite = InferSelectModel<typeof userSites>;
export type RoleResource = InferSelectModel<typeof roleResources>;
export type UserResource = InferSelectModel<typeof userResources>;
export type Limit = InferSelectModel<typeof limitsTable>;
export type Limit = InferSelectModel<typeof limitsTable>;