mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-20 19:51:09 +10:00
partial: user routes
This commit is contained in:
@ -1,8 +1,16 @@
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import taskHandler from "~/server/internal/tasks";
|
||||
import authManager from "~/server/internal/auth";
|
||||
import { ArkErrors, type } from "arktype";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const Query = type({
|
||||
id: "string",
|
||||
});
|
||||
|
||||
/**
|
||||
* Fetch invitation details for pre-filling
|
||||
*/
|
||||
export default defineEventHandler<{ query: typeof Query.infer }>(async (h3) => {
|
||||
const t = await useTranslation(h3);
|
||||
|
||||
if (!authManager.getAuthProviders().Simple)
|
||||
@ -11,13 +19,13 @@ export default defineEventHandler(async (h3) => {
|
||||
statusMessage: t("errors.auth.method.signinDisabled"),
|
||||
});
|
||||
|
||||
const query = getQuery(h3);
|
||||
const id = query.id?.toString();
|
||||
if (!id)
|
||||
const query = Query(getQuery(h3));
|
||||
if (query instanceof ArkErrors)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: t("errors.auth.inviteIdRequired"),
|
||||
statusMessage: "Invalid query: " + query.summary,
|
||||
});
|
||||
const id = query.id;
|
||||
taskHandler.runTaskGroupByName("cleanup:invitations");
|
||||
|
||||
const invitation = await prisma.invitation.findUnique({ where: { id: id } });
|
||||
|
||||
Reference in New Issue
Block a user