mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-01-31 15:37:09 +01:00
User invite uses external domain option (#118)
* feat: user invite uses external domain option fixes #117 * fix: inconsistent external url format * fix: normalize external url more cleanly
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
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";
|
||||
|
||||
@@ -10,6 +11,13 @@ export default defineEventHandler(async (h3) => {
|
||||
|
||||
await taskHandler.runTaskGroupByName("cleanup:invitations");
|
||||
|
||||
const externalUrl = systemConfig.getExternalUrl();
|
||||
const invitations = await prisma.invitation.findMany({});
|
||||
return invitations;
|
||||
|
||||
return invitations.map((invitation) => {
|
||||
return {
|
||||
...invitation,
|
||||
inviteUrl: `${externalUrl}/auth/register?id=${invitation.id}`,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { SharedRegisterValidator } from "../../../auth/signup/simple.post";
|
||||
import { systemConfig } from "~/server/internal/config/sys-conf";
|
||||
|
||||
const CreateInvite = SharedRegisterValidator.partial()
|
||||
.and({
|
||||
@@ -22,5 +23,8 @@ export default defineEventHandler(async (h3) => {
|
||||
data: body,
|
||||
});
|
||||
|
||||
return invitation;
|
||||
return {
|
||||
...invitation,
|
||||
inviteUrl: `${systemConfig.getExternalUrl()}/auth/register?id=${invitation.id}`,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import normalizeUrl from "normalize-url";
|
||||
|
||||
class SystemConfig {
|
||||
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
|
||||
private dataFolder = process.env.DATA ?? "./.data/data";
|
||||
|
||||
private externalUrl = process.env.EXTERNAL_URL ?? "http://localhost:3000";
|
||||
private externalUrl = normalizeUrl(
|
||||
process.env.EXTERNAL_URL ?? "http://localhost:3000",
|
||||
{ stripWWW: false },
|
||||
);
|
||||
private dropVersion;
|
||||
private gitRef;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user