mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 10:15:04 +00:00
fix host, error handling
This commit is contained in:
@@ -174,7 +174,7 @@ export async function GET(request: NextRequest) {
|
||||
const idp = identityProviders.find((idp) => idp.id === idpId);
|
||||
|
||||
if (idp) {
|
||||
const host = request.nextUrl.origin;
|
||||
const origin = request.nextUrl.origin;
|
||||
|
||||
const identityProviderType = identityProviders[0].type;
|
||||
let provider = idpTypeToSlug(identityProviderType);
|
||||
@@ -193,10 +193,10 @@ export async function GET(request: NextRequest) {
|
||||
idpId,
|
||||
urls: {
|
||||
successUrl:
|
||||
`${host}/idp/${provider}/success?` +
|
||||
`${origin}/idp/${provider}/success?` +
|
||||
new URLSearchParams(params),
|
||||
failureUrl:
|
||||
`${host}/idp/${provider}/failure?` +
|
||||
`${origin}/idp/${provider}/failure?` +
|
||||
new URLSearchParams(params),
|
||||
},
|
||||
}).then((resp) => {
|
||||
|
||||
@@ -54,6 +54,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
|
||||
if (identityProviders.length === 1) {
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!host) {
|
||||
return { error: "Could not get host" };
|
||||
}
|
||||
|
||||
const identityProviderType = identityProviders[0].type;
|
||||
|
||||
const provider = idpTypeToSlug(identityProviderType);
|
||||
@@ -72,9 +77,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
idpId: identityProviders[0].id,
|
||||
urls: {
|
||||
successUrl:
|
||||
`${host}/idp/${provider}/success?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/success?` +
|
||||
new URLSearchParams(params),
|
||||
failureUrl:
|
||||
`${host}/idp/${provider}/failure?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/failure?` +
|
||||
new URLSearchParams(params),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -91,6 +98,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
|
||||
if (identityProviders.length === 1) {
|
||||
const host = (await headers()).get("host");
|
||||
|
||||
if (!host) {
|
||||
return { error: "Could not get host" };
|
||||
}
|
||||
|
||||
const identityProviderId = identityProviders[0].idpId;
|
||||
|
||||
const idp = await getIDPByID(identityProviderId);
|
||||
@@ -118,9 +130,11 @@ export async function sendLoginname(command: SendLoginnameCommand) {
|
||||
idpId: idp.id,
|
||||
urls: {
|
||||
successUrl:
|
||||
`${host}/idp/${provider}/success?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/success?` +
|
||||
new URLSearchParams(params),
|
||||
failureUrl:
|
||||
`${host}/idp/${provider}/failure?` + new URLSearchParams(params),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/idp/${provider}/failure?` +
|
||||
new URLSearchParams(params),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user