Skip to content

Commit dc49633

Browse files
committed
Merge branch 'main' into feat/add-pkce-like-session-binding
2 parents c5c5882 + 993c695 commit dc49633

File tree

20 files changed

+1773
-92
lines changed

20 files changed

+1773
-92
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
- name: Setup
5555
uses: ./tooling/github/setup
5656

57+
- name: Copy env
58+
shell: bash
59+
run: cp .env.example .env
60+
5761
- name: Typecheck
5862
run: pnpm typecheck
5963
# TODO: Add test CI

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"with-env": "dotenv -e ../../.env --",
1515
"test": "vitest",
1616
"storybook": "CI=1 storybook dev -p 6006",
17+
"docker": "docker-compose up",
1718
"build-storybook": "CI=1 storybook build"
1819
},
1920
"dependencies": {

apps/web/src/server/modules/auth/auth.service.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,26 @@ export const emailVerifyOtp = async ({
121121
})
122122
}
123123

124+
// NOTE: You can also use `kysely` for your queries
125+
// if you want more fine-grained control.
124126
// Valid token, delete record to prevent reuse
125-
return db.verificationToken.delete({
126-
where: {
127-
identifier: vfnIdentifier,
128-
},
129-
})
127+
return db.$kysely
128+
.deleteFrom('VerificationToken')
129+
.where('identifier', '=', vfnIdentifier)
130+
.returningAll()
131+
.executeTakeFirstOrThrow(
132+
// NOTE: If we are unable to find the token,
133+
// this means that it has been deleted between
134+
// our initial query and the deletion here
135+
() =>
136+
new TRPCError({
137+
code: 'BAD_REQUEST',
138+
message:
139+
'Token is invalid or has expired. Please request a new OTP.',
140+
}),
141+
)
130142
} catch (error) {
131-
// see error code here: https://www.prisma.io/docs/reference/api-reference/error-reference#p2025
143+
// see error code here: https://www.prisma.io/docs/orm/reference/error-reference#p2025
132144
if (
133145
error instanceof Prisma.PrismaClientKnownRequestError &&
134146
error.code === 'P2025'

apps/web/turbo.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
"dependsOn": ["^build"],
77
"outputs": [".next/**", "!.next/cache/**", "next-env.d.ts"]
88
},
9+
"docker": {
10+
"cache": false
11+
},
912
"dev": {
10-
"persistent": true
13+
"persistent": true,
14+
"dependsOn": ["docker"]
1115
}
1216
}
1317
}

apps/web/vercel.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"buildCommand": "turbo vercel-build"
4+
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- POSTGRES_USER=root
99
- POSTGRES_PASSWORD=root
1010
volumes:
11-
- postgres-volume:/var/lib/postgresql/data
11+
- postgres-volume:/var/lib/postgresql
1212

1313
volumes:
1414
postgres-volume:

0 commit comments

Comments
 (0)