| 91 | } |
| 92 | |
| 93 | export async function checkFingerprintConflict( |
| 94 | fingerprintId: string, |
| 95 | userId: string, |
| 96 | ): Promise<{ hasConflict: boolean; existingUserId?: string }> { |
| 97 | const existingSession = await db |
| 98 | .select({ |
| 99 | userId: schema.session.userId, |
| 100 | }) |
| 101 | .from(schema.session) |
| 102 | .where( |
| 103 | and( |
| 104 | eq(schema.session.fingerprint_id, fingerprintId), |
| 105 | ne(schema.session.userId, userId), |
| 106 | gt(schema.session.expires, new Date()), |
| 107 | ), |
| 108 | ) |
| 109 | .limit(1) |
| 110 | |
| 111 | const activeSession = existingSession[0] |
| 112 | if (activeSession) { |
| 113 | return { hasConflict: true, existingUserId: activeSession.userId } |
| 114 | } |
| 115 | return { hasConflict: false } |
| 116 | } |
| 117 | |
| 118 | export async function getSessionTokenFromCookies(): Promise< |
| 119 | string | undefined |