fix(portal): add invitation links and correct customer login routing
All checks were successful
Build and Release FEDEO / verify (push) Successful in 1m7s
Build and Release FEDEO / build-and-release (push) Successful in 6m24s

This commit is contained in:
2026-10-13 18:13:41 +02:00
parent 070be08207
commit 5463106938
10 changed files with 302 additions and 29 deletions

View File

@@ -33,6 +33,7 @@ import { requireSystemAdmin } from "../utils/requireSystemAdmin";
import { buildSystemStatus } from "../modules/system-status.service";
import { s3 } from "../utils/s3";
import { secrets } from "../utils/secrets";
import { getPortalLoginUrl } from "../utils/portalUrl";
export default async function adminRoutes(server: FastifyInstance) {
await server.register(multipart, {
@@ -931,6 +932,17 @@ export default async function adminRoutes(server: FastifyInstance) {
return reply.code(400).send({ error: "Customer has no email address" });
}
let portalUrl: string;
try {
portalUrl = getPortalLoginUrl({
portalDomain: tenantRecord?.portalDomain,
publicUrl: process.env.FEDEO_PUBLIC_URL,
apiBaseUrl: secrets.API_BASE_URL,
});
} catch (err: any) {
return reply.code(503).send({ error: err.message });
}
const generatedPassword = generateRandomPassword(14);
const passwordHash = await hashPassword(generatedPassword);
@@ -1086,8 +1098,6 @@ export default async function adminRoutes(server: FastifyInstance) {
});
}
const portalUrl = tenantRecord?.portalDomain ? `https://${tenantRecord.portalDomain}/login` : null;
const mailResult = await sendMail(
email,
`FEDEO | Einladung ins Kundenportal`,
@@ -1097,7 +1107,8 @@ export default async function adminRoutes(server: FastifyInstance) {
<p><strong>E-Mail:</strong> ${email}</p>
<p><strong>Initialpasswort:</strong> ${generatedPassword}</p>
<p>Bitte ändern Sie dieses Passwort direkt nach dem ersten Login.</p>
${portalUrl ? `<p><strong>Login:</strong> <a href="${portalUrl}">${portalUrl}</a></p>` : ""}
<p><a href="${portalUrl}">Zum Kundenportal anmelden</a></p>
<p>Ihre Login-Adresse: ${portalUrl}</p>
<p>Viele Grüße<br>${tenantRecord?.name || "FEDEO"}</p>
`
);