use origin header instead of host

This commit is contained in:
Max Peintner
2024-12-03 14:31:50 +01:00
parent 30091ddb17
commit 017c3215eb
9 changed files with 32 additions and 40 deletions

View File

@@ -267,15 +267,15 @@ export async function resendInviteCode(userId: string) {
return userService.resendInviteCode({ userId }, {});
}
export async function createInviteCode(userId: string, host: string | null) {
export async function createInviteCode(userId: string, origin: string | null) {
let medium = create(SendInviteCodeSchema, {
applicationName: "Typescript Login",
});
if (host) {
if (origin) {
medium = {
...medium,
urlTemplate: `${host.includes("localhost") ? "http://" : "https://"}${host}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true`,
urlTemplate: `${origin}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true`,
};
}
@@ -506,18 +506,18 @@ export function createUser(
*/
export async function passwordReset(
userId: string,
host: string | null,
origin: string | null,
authRequestId?: string,
) {
let medium = create(SendPasswordResetLinkSchema, {
notificationType: NotificationType.Email,
});
if (host) {
if (origin) {
medium = {
...medium,
urlTemplate:
`${host.includes("localhost") ? "http://" : "https://"}${host}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
`${origin}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
};
}