chore: Add support for conversation_id in SSO params (#5228)
This commit is contained in:
parent
4b1bb65c92
commit
27a9806817
5 changed files with 54 additions and 14 deletions
|
@ -5,16 +5,31 @@ export const frontendURL = (path, params) => {
|
|||
return `/app/${path}${stringifiedParams}`;
|
||||
};
|
||||
|
||||
export const getLoginRedirectURL = (ssoAccountId, user) => {
|
||||
const getSSOAccountPath = ({ ssoAccountId, user }) => {
|
||||
const { accounts = [] } = user || {};
|
||||
const ssoAccount = accounts.find(
|
||||
account => account.id === Number(ssoAccountId)
|
||||
);
|
||||
let accountPath = '';
|
||||
if (ssoAccount) {
|
||||
return frontendURL(`accounts/${ssoAccountId}/dashboard`);
|
||||
accountPath = `accounts/${ssoAccountId}`;
|
||||
} else if (accounts.length) {
|
||||
accountPath = `accounts/${accounts[0].id}`;
|
||||
}
|
||||
if (accounts.length) {
|
||||
return frontendURL(`accounts/${accounts[0].id}/dashboard`);
|
||||
return accountPath;
|
||||
};
|
||||
|
||||
export const getLoginRedirectURL = ({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
user,
|
||||
}) => {
|
||||
const accountPath = getSSOAccountPath({ ssoAccountId, user });
|
||||
if (accountPath) {
|
||||
if (ssoConversationId) {
|
||||
return frontendURL(`${accountPath}/conversations/${ssoConversationId}`);
|
||||
}
|
||||
return frontendURL(`${accountPath}/dashboard`);
|
||||
}
|
||||
return DEFAULT_REDIRECT_URL;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue