mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-01-31 15:37:09 +01:00
Fix MFA superlevel redirect & ViewTransition (#314)
* feat: fix mfa superlevel & viewtransition * fix: lint
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -33,7 +33,7 @@
|
||||
"username": "drop"
|
||||
}
|
||||
],
|
||||
"typescript.experimental.useTsgo": true,
|
||||
"typescript.experimental.useTsgo": false,
|
||||
// prioritize ArkType's "type" for autoimports
|
||||
"typescript.preferences.autoImportSpecifierExcludeRegexes": ["^(node:)?os$"]
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export default defineNuxtConfig({
|
||||
|
||||
experimental: {
|
||||
buildCache: true,
|
||||
viewTransition: true,
|
||||
viewTransition: false,
|
||||
componentIslands: true,
|
||||
},
|
||||
|
||||
|
||||
@@ -202,7 +202,6 @@ async function createToken(
|
||||
},
|
||||
failTitle: "Failed to create API token.",
|
||||
});
|
||||
console.log(result);
|
||||
newToken.value = result.token;
|
||||
tokens.value.push(result);
|
||||
} finally {
|
||||
|
||||
8
server/api/v1/client/depots/index.get.ts
Normal file
8
server/api/v1/client/depots/index.get.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
|
||||
export default defineClientEventHandler(async () => {
|
||||
const depots = await prisma.depot.findMany({ select: { endpoint: true } });
|
||||
|
||||
return depots;
|
||||
});
|
||||
@@ -1,5 +1,23 @@
|
||||
import type { Platform } from "~/prisma/client/enums";
|
||||
import { defineClientEventHandler } from "~/server/internal/clients/event-handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import gameSizeManager from "~/server/internal/gamesize";
|
||||
|
||||
type VersionDownloadOption = {
|
||||
versionId: string;
|
||||
displayName?: string;
|
||||
versionPath: string;
|
||||
platform: Platform;
|
||||
size: number;
|
||||
requiredContent: Array<{
|
||||
gameId: string;
|
||||
versionId: string;
|
||||
name: string;
|
||||
iconObjectId: string;
|
||||
shortDescription: string;
|
||||
size: number;
|
||||
}>;
|
||||
};
|
||||
|
||||
export default defineClientEventHandler(async (h3) => {
|
||||
const query = getQuery(h3);
|
||||
@@ -10,21 +28,94 @@ export default defineClientEventHandler(async (h3) => {
|
||||
statusMessage: "No ID in request query",
|
||||
});
|
||||
|
||||
const versions = await prisma.gameVersion.findMany({
|
||||
const rawVersions = await prisma.gameVersion.findMany({
|
||||
where: {
|
||||
gameId: id,
|
||||
},
|
||||
orderBy: {
|
||||
versionIndex: "desc", // Latest one first
|
||||
},
|
||||
omit: {
|
||||
dropletManifest: true,
|
||||
},
|
||||
include: {
|
||||
launches: true,
|
||||
setups: true,
|
||||
select: {
|
||||
versionId: true,
|
||||
displayName: true,
|
||||
versionPath: true,
|
||||
gameId: true,
|
||||
launches: {
|
||||
select: {
|
||||
platform: true,
|
||||
executor: {
|
||||
select: {
|
||||
gameVersion: {
|
||||
select: {
|
||||
game: {
|
||||
select: {
|
||||
mName: true,
|
||||
mShortDescription: true,
|
||||
mIconObjectId: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
versionId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const versions: Array<VersionDownloadOption> = (
|
||||
await Promise.all(
|
||||
rawVersions.map(async (v) => {
|
||||
const platformOptions: Map<
|
||||
Platform,
|
||||
VersionDownloadOption["requiredContent"]
|
||||
> = new Map();
|
||||
|
||||
for (const launch of v.launches) {
|
||||
if (!platformOptions.has(launch.platform))
|
||||
platformOptions.set(launch.platform, []);
|
||||
|
||||
if (launch.executor) {
|
||||
const old = platformOptions.get(launch.platform)!;
|
||||
old.push({
|
||||
gameId: launch.executor.gameVersion.game.id,
|
||||
versionId: launch.executor.gameVersion.versionId,
|
||||
name: launch.executor.gameVersion.game.mName,
|
||||
iconObjectId: launch.executor.gameVersion.game.mIconObjectId,
|
||||
shortDescription:
|
||||
launch.executor.gameVersion.game.mShortDescription,
|
||||
size:
|
||||
(await gameSizeManager.getGameVersionSize(
|
||||
launch.executor.gameVersion.game.id,
|
||||
launch.executor.gameVersion.versionId,
|
||||
)) ?? 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const size = await gameSizeManager.getGameVersionSize(
|
||||
v.gameId,
|
||||
v.versionId,
|
||||
);
|
||||
|
||||
return platformOptions
|
||||
.entries()
|
||||
.map(
|
||||
([platform, requiredContent]) =>
|
||||
({
|
||||
versionId: v.versionId,
|
||||
versionPath: v.versionPath,
|
||||
platform,
|
||||
requiredContent,
|
||||
size: size!,
|
||||
}) satisfies VersionDownloadOption,
|
||||
)
|
||||
.toArray();
|
||||
}),
|
||||
)
|
||||
).flat();
|
||||
|
||||
return versions;
|
||||
});
|
||||
|
||||
@@ -55,17 +55,20 @@ export class SessionHandler {
|
||||
data: {},
|
||||
};
|
||||
const wasAuthenticated = !!session.authenticated;
|
||||
|
||||
session.authenticated = {
|
||||
userId,
|
||||
level: session.authenticated?.level ?? 10,
|
||||
requiredLevel: mfaCount > 0 ? 20 : 10,
|
||||
superleveledExpiry: undefined,
|
||||
};
|
||||
|
||||
if (
|
||||
!wasAuthenticated &&
|
||||
wasAuthenticated &&
|
||||
session.authenticated.level >= session.authenticated.requiredLevel
|
||||
)
|
||||
) {
|
||||
session.authenticated.superleveledExpiry = Date.now() + SUPERLEVEL_LENGTH;
|
||||
}
|
||||
const success = await this.sessionProvider.setSession(token, session);
|
||||
if (!success) return "fail";
|
||||
|
||||
@@ -123,7 +126,6 @@ export class SessionHandler {
|
||||
expiresAt,
|
||||
data: {},
|
||||
};
|
||||
console.log(session);
|
||||
session.data[key] = value;
|
||||
await this.sessionProvider.setSession(token, session);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user