mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
* feat: user invite uses external domain option fixes #117 * fix: inconsistent external url format * fix: normalize external url more cleanly
24 lines
764 B
TypeScript
24 lines
764 B
TypeScript
import aclManager from "~/server/internal/acls";
|
|
import { systemConfig } from "~/server/internal/config/sys-conf";
|
|
import prisma from "~/server/internal/db/database";
|
|
import taskHandler from "~/server/internal/tasks";
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const allowed = await aclManager.allowSystemACL(h3, [
|
|
"auth:simple:invitation:read",
|
|
]);
|
|
if (!allowed) throw createError({ statusCode: 403 });
|
|
|
|
await taskHandler.runTaskGroupByName("cleanup:invitations");
|
|
|
|
const externalUrl = systemConfig.getExternalUrl();
|
|
const invitations = await prisma.invitation.findMany({});
|
|
|
|
return invitations.map((invitation) => {
|
|
return {
|
|
...invitation,
|
|
inviteUrl: `${externalUrl}/auth/register?id=${invitation.id}`,
|
|
};
|
|
});
|
|
});
|