Add an option to checkAuth to update the user's latest IP

This commit is contained in:
2026-01-22 18:31:48 -07:00
parent c62d4033d5
commit b4a9d26d0f
9 changed files with 104 additions and 23 deletions

View File

@@ -1,5 +1,9 @@
import { Context } from 'elysia'
import { getDatabaseConnection, jsonResponse } from '../../../lib/util'
import {
getClientIp,
getDatabaseConnection,
jsonResponse
} from '../../../lib/util'
import { berryDashMarketplaceIcons, users } from '../../../lib/tables'
import { and, eq, inArray, or, sql, not } from 'drizzle-orm'
import { checkAuthorization } from '../../../lib/bd/auth'
@@ -41,8 +45,14 @@ export async function handler (context: Context) {
const { connection: connection0, db: db0 } = dbInfo0
const { connection: connection1, db: db1 } = dbInfo1
const ip = getClientIp(context)
const authorizationToken = context.headers.authorization
const authResult = await checkAuthorization(authorizationToken as string, db1)
const authResult = await checkAuthorization(
authorizationToken as string,
db1,
db0,
ip
)
if (!authResult.valid) {
connection0.end()
connection1.end()