Fix merge conflicts and add withTransaction helper
- Add withTransaction helper that gracefully handles nested transactions (reuses existing transaction in tests, starts new one otherwise) - Update auth procedures to use withTransaction instead of direct .transaction() - Add email config to all e2e test contexts (required by merged code) - Remove duplicate verification token code from signup procedure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* e. Return { status: 'completed', redirectTo: '/dashboard' or '/auth/trust-device' }
|
||||
*/
|
||||
|
||||
import { withTransaction } from "@reviq/db";
|
||||
import {
|
||||
COOKIE_NAMES,
|
||||
COOKIE_OPTIONS,
|
||||
@@ -90,9 +91,9 @@ export const loginIfRequestIsCompleted =
|
||||
const userAgent = getUserAgent(context.reqHeaders);
|
||||
|
||||
// Create session in transaction (atomic: device upsert + session + login_request delete)
|
||||
const { session, deviceTrusted } = await context.db
|
||||
.transaction()
|
||||
.execute(async (trx) => {
|
||||
const { session, deviceTrusted } = await withTransaction(
|
||||
context.db,
|
||||
async (trx) => {
|
||||
// Upsert user device
|
||||
const deviceId = await upsertUserDevice(
|
||||
trx,
|
||||
|
||||
Reference in New Issue
Block a user