完善 H5 鉴权与登录流程

This commit is contained in:
inman
2026-07-24 14:55:13 +08:00
parent 160e82197e
commit c820a56e79
18 changed files with 1130 additions and 82 deletions

View File

@@ -0,0 +1,18 @@
CREATE TABLE "H5AuthTicket" (
"id" TEXT NOT NULL,
"tokenHash" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3) NOT NULL,
"consumedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "H5AuthTicket_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "H5AuthTicket_tokenHash_key" ON "H5AuthTicket"("tokenHash");
CREATE INDEX "H5AuthTicket_expiresAt_idx" ON "H5AuthTicket"("expiresAt");
CREATE INDEX "H5AuthTicket_userId_createdAt_idx" ON "H5AuthTicket"("userId", "createdAt");
ALTER TABLE "H5AuthTicket"
ADD CONSTRAINT "H5AuthTicket_userId_fkey"
FOREIGN KEY ("userId") REFERENCES "MiniProgramUser"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -264,12 +264,26 @@ model MiniProgramUser {
favorites MiniProgramFavorite[]
histories MiniProgramHistory[]
wecomContacts WecomExternalContact[]
h5AuthTickets H5AuthTicket[]
@@unique([appId, openId])
@@index([phone])
@@index([status, lastLoginAt])
}
model H5AuthTicket {
id String @id @default(uuid())
tokenHash String @unique
userId String
user MiniProgramUser @relation(fields: [userId], references: [id], onDelete: Cascade)
expiresAt DateTime
consumedAt DateTime?
createdAt DateTime @default(now())
@@index([expiresAt])
@@index([userId, createdAt])
}
model MiniProgramFavorite {
id String @id @default(uuid())
userId String