2024-10-30 13:59:03 +01:00
|
|
|
type FinishFlowCommand =
|
|
|
|
|
| {
|
|
|
|
|
sessionId: string;
|
2025-02-05 09:13:43 +01:00
|
|
|
requestId: string;
|
2024-10-30 13:59:03 +01:00
|
|
|
}
|
|
|
|
|
| { loginName: string };
|
|
|
|
|
|
|
|
|
|
/**
|
2025-02-05 09:13:43 +01:00
|
|
|
* for client: redirects user back to an OIDC or SAML application or to a success page when using requestId, check if a default redirect and redirect to it, or just redirect to a success page with the loginName
|
2024-10-30 13:59:03 +01:00
|
|
|
* @param command
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
2024-11-21 10:48:00 +01:00
|
|
|
export async function getNextUrl(
|
2024-10-30 13:59:03 +01:00
|
|
|
command: FinishFlowCommand & { organization?: string },
|
2024-11-21 10:48:00 +01:00
|
|
|
defaultRedirectUri?: string,
|
|
|
|
|
): Promise<string> {
|
2025-02-05 09:13:43 +01:00
|
|
|
if ("sessionId" in command && "requestId" in command) {
|
2024-11-28 09:59:37 +01:00
|
|
|
const params = new URLSearchParams({
|
|
|
|
|
sessionId: command.sessionId,
|
2025-02-05 09:13:43 +01:00
|
|
|
requestId: command.requestId,
|
2024-11-28 09:59:37 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (command.organization) {
|
|
|
|
|
params.append("organization", command.organization);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `/login?` + params;
|
2024-11-18 17:30:46 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-21 10:48:00 +01:00
|
|
|
if (defaultRedirectUri) {
|
|
|
|
|
return defaultRedirectUri;
|
2024-11-18 17:30:46 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-28 09:59:37 +01:00
|
|
|
const params = new URLSearchParams({
|
|
|
|
|
loginName: command.loginName,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (command.organization) {
|
|
|
|
|
params.append("organization", command.organization);
|
|
|
|
|
}
|
2024-11-21 10:48:00 +01:00
|
|
|
|
2024-11-28 09:59:37 +01:00
|
|
|
return `/signedin?` + params;
|
2024-10-30 13:59:03 +01:00
|
|
|
}
|