2024-10-30 13:59:03 +01:00
|
|
|
type FinishFlowCommand =
|
|
|
|
|
| {
|
|
|
|
|
sessionId: string;
|
|
|
|
|
authRequestId: string;
|
|
|
|
|
}
|
|
|
|
|
| { loginName: string };
|
|
|
|
|
|
|
|
|
|
/**
|
2024-11-18 17:30:46 +01:00
|
|
|
* for client: redirects user back to OIDC application or to a success page when using authRequestId, 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> {
|
2024-11-18 17:30:46 +01:00
|
|
|
if ("sessionId" in command && "authRequestId" in command) {
|
2024-11-28 09:59:37 +01:00
|
|
|
const params = new URLSearchParams({
|
|
|
|
|
sessionId: command.sessionId,
|
|
|
|
|
authRequest: command.authRequestId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|