Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/lib/server/auth.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe("使わない個人情報を DB に保存しない", () => {
userId: user.id,
providerId: "google",
accountId: "1234567890",
issuer: "https://accounts.google.com",
...tokens,
});
await ctx.internalAdapter.updateAccount(account.id, tokens);
Expand Down
3 changes: 1 addition & 2 deletions app/lib/server/drop-unused-personal-data.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ beforeAll(async () => {

// 本番に保存済みのトークン・IP アドレス・本物のメールと画像を、デプロイ時に消すマイグレーション
it("保存済みの使わない個人情報を消し、ログインに要る Google のユーザー ID とパスワードは残す", async () => {
const google = { providerId: "google", issuer: "https://accounts.google.com" };
const google = { providerId: "google" };
const tokens = { accessToken: "ya29.xxx", idToken: "eyJ.xxx", accessTokenExpiresAt: new Date() };
// Google で新規登録したユーザー
await prisma.user.create({
Expand Down Expand Up @@ -42,7 +42,6 @@ it("保存済みの使わない個人情報を消し、ログインに要る Goo
id: "pc",
accountId: "p",
providerId: "credential",
issuer: "local:credential",
password: "hashed",
},
{ id: "pg", accountId: "222", ...google, ...tokens },
Expand Down
155 changes: 75 additions & 80 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@react-router/serve": "^8.4.0",
"@resvg/resvg-js": "^2.6.2",
"@types/mdx": "^2.0.14",
"better-auth": "^1.7.2",
"better-auth": "^1.7.7",
"exceljs": "^4.4.0",
"isbot": "^5.2.2",
"pinyin": "^4.0.0",
Expand Down Expand Up @@ -53,6 +53,9 @@
"vitest": "5.0.5"
},
"overrides": {
"exceljs": {
"uuid": "^11.1.1"
},
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
"vitest": "5.0.5"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Better Auth 1.7.3 以降はアカウント識別に issuer を使わないため、不要な列と一意制約を取り除く。
DROP INDEX "accounts_issuer_accountId_key";
ALTER TABLE "accounts" DROP COLUMN "issuer";
CREATE UNIQUE INDEX "accounts_providerId_accountId_key" ON "accounts"("providerId", "accountId");
6 changes: 2 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ model Session {

model Account {
id String @id
// ログイン方法の種類(email/password なら "local:credential")。
// better-auth 1.7 以降、同一providerId内でaccountIdの一意性を保証するために追加されたフィールド
issuer String
// ログイン方法の種類(email/password なら "credential"、Google なら "google")
accountId String
providerId String
userId String
Expand All @@ -267,7 +265,7 @@ model Account {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@unique([issuer, accountId])
@@unique([providerId, accountId])
@@index([userId])
@@map("accounts")
}
Expand Down
Loading