mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:32:39 +00:00
Revert "use origin header instead of host"
This reverts commit 017c3215eb.
This commit is contained in:
@@ -110,6 +110,10 @@ export default async function Page(props: {
|
||||
params.set("authRequestId", authRequestId);
|
||||
}
|
||||
|
||||
const host = process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}`
|
||||
: "http://localhost:3000";
|
||||
|
||||
return (
|
||||
<DynamicTheme branding={branding}>
|
||||
<div className="flex flex-col items-center space-y-4">
|
||||
|
||||
@@ -31,7 +31,7 @@ export default async function Page(props: {
|
||||
|
||||
const loginSettings = await getLoginSettings(organization);
|
||||
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
return (
|
||||
<DynamicTheme branding={branding}>
|
||||
@@ -70,7 +70,7 @@ export default async function Page(props: {
|
||||
organization={organization}
|
||||
method={method}
|
||||
loginSettings={loginSettings}
|
||||
origin={origin}
|
||||
host={host}
|
||||
code={code}
|
||||
></LoginOTP>
|
||||
)}
|
||||
|
||||
@@ -25,7 +25,7 @@ type Props = {
|
||||
method: string;
|
||||
code?: string;
|
||||
loginSettings?: LoginSettings;
|
||||
origin: string | null;
|
||||
host: string | null;
|
||||
};
|
||||
|
||||
type Inputs = {
|
||||
@@ -40,7 +40,7 @@ export function LoginOTP({
|
||||
method,
|
||||
code,
|
||||
loginSettings,
|
||||
origin,
|
||||
host,
|
||||
}: Props) {
|
||||
const t = useTranslations("otp");
|
||||
|
||||
@@ -81,10 +81,10 @@ export function LoginOTP({
|
||||
otpEmail: {
|
||||
deliveryType: {
|
||||
case: "sendCode",
|
||||
value: origin
|
||||
value: host
|
||||
? {
|
||||
urlTemplate:
|
||||
`${origin}/otp/method=${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}&organization={{.OrgID}}` +
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/otp/method=${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}&organization={{.OrgID}}` +
|
||||
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
|
||||
}
|
||||
: {},
|
||||
|
||||
@@ -10,17 +10,17 @@ export type StartIDPFlowCommand = {
|
||||
};
|
||||
|
||||
export async function startIDPFlow(command: StartIDPFlowCommand) {
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!origin) {
|
||||
return { error: "Could not get origin" };
|
||||
if (!host) {
|
||||
return { error: "Could not get host" };
|
||||
}
|
||||
|
||||
return startIdentityProviderFlow({
|
||||
idpId: command.idpId,
|
||||
urls: {
|
||||
successUrl: `${origin}${command.successUrl}`,
|
||||
failureUrl: `${origin}${command.failureUrl}`,
|
||||
successUrl: `${host.includes("localhost") ? "http://" : "https://"}${host}${command.successUrl}`,
|
||||
failureUrl: `${host.includes("localhost") ? "http://" : "https://"}${host}${command.failureUrl}`,
|
||||
},
|
||||
}).then((response) => {
|
||||
if (
|
||||
|
||||
@@ -20,7 +20,7 @@ export type RegisterUserResponse = {
|
||||
};
|
||||
|
||||
export async function inviteUser(command: InviteUserCommand) {
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
const human = await addHumanUser({
|
||||
email: command.email,
|
||||
@@ -34,7 +34,7 @@ export async function inviteUser(command: InviteUserCommand) {
|
||||
return { error: "Could not create user" };
|
||||
}
|
||||
|
||||
const codeResponse = await createInviteCode(human.userId, origin);
|
||||
const codeResponse = await createInviteCode(human.userId, host);
|
||||
|
||||
if (!codeResponse || !human) {
|
||||
return { error: "Could not create invite code" };
|
||||
|
||||
@@ -53,10 +53,10 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
});
|
||||
|
||||
if (identityProviders.length === 1) {
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!origin) {
|
||||
return { error: "Could not get origin" };
|
||||
if (!host) {
|
||||
return { error: "Could not get host" };
|
||||
}
|
||||
|
||||
const identityProviderType = identityProviders[0].type;
|
||||
@@ -77,9 +77,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
idpId: identityProviders[0].id,
|
||||
urls: {
|
||||
successUrl:
|
||||
`${origin}/idp/${provider}/success?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/success?` +
|
||||
new URLSearchParams(params),
|
||||
failureUrl:
|
||||
`${origin}/idp/${provider}/failure?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/failure?` +
|
||||
new URLSearchParams(params),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -95,10 +97,10 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
});
|
||||
|
||||
if (identityProviders.length === 1) {
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!origin) {
|
||||
return { error: "Could not get origin" };
|
||||
if (!host) {
|
||||
return { error: "Could not get host" };
|
||||
}
|
||||
|
||||
const identityProviderId = identityProviders[0].idpId;
|
||||
@@ -128,9 +130,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
idpId: idp.id,
|
||||
urls: {
|
||||
successUrl:
|
||||
`${origin}/idp/${provider}/success?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/success?` +
|
||||
new URLSearchParams(params),
|
||||
failureUrl:
|
||||
`${origin}/idp/${provider}/failure?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/failure?` +
|
||||
new URLSearchParams(params),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function registerPasskeyLink(
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!host) {
|
||||
throw new Error("Could not get host");
|
||||
throw new Error("Could not get domain");
|
||||
}
|
||||
|
||||
const [hostname, port] = host.split(":");
|
||||
|
||||
@@ -31,7 +31,7 @@ type ResetPasswordCommand = {
|
||||
};
|
||||
|
||||
export async function resetPassword(command: ResetPasswordCommand) {
|
||||
const origin = (await headers()).get("origin");
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
const users = await listUsers({
|
||||
loginName: command.loginName,
|
||||
@@ -47,7 +47,7 @@ export async function resetPassword(command: ResetPasswordCommand) {
|
||||
}
|
||||
const userId = users.result[0].userId;
|
||||
|
||||
return passwordReset(userId, origin, command.authRequestId);
|
||||
return passwordReset(userId, host, command.authRequestId);
|
||||
}
|
||||
|
||||
export type UpdateSessionCommand = {
|
||||
|
||||
@@ -267,15 +267,15 @@ export async function resendInviteCode(userId: string) {
|
||||
return userService.resendInviteCode({ userId }, {});
|
||||
}
|
||||
|
||||
export async function createInviteCode(userId: string, origin: string | null) {
|
||||
export async function createInviteCode(userId: string, host: string | null) {
|
||||
let medium = create(SendInviteCodeSchema, {
|
||||
applicationName: "Typescript Login",
|
||||
});
|
||||
|
||||
if (origin) {
|
||||
if (host) {
|
||||
medium = {
|
||||
...medium,
|
||||
urlTemplate: `${origin}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true`,
|
||||
urlTemplate: `${host.includes("localhost") ? "http://" : "https://"}${host}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -506,18 +506,18 @@ export function createUser(
|
||||
*/
|
||||
export async function passwordReset(
|
||||
userId: string,
|
||||
origin: string | null,
|
||||
host: string | null,
|
||||
authRequestId?: string,
|
||||
) {
|
||||
let medium = create(SendPasswordResetLinkSchema, {
|
||||
notificationType: NotificationType.Email,
|
||||
});
|
||||
|
||||
if (origin) {
|
||||
if (host) {
|
||||
medium = {
|
||||
...medium,
|
||||
urlTemplate:
|
||||
`${origin}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
|
||||
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user