feat(shopify): Support Shopify-initiated install flow and improve integration page
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
export const login = async ({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
redirectUrl,
|
||||
...credentials
|
||||
}) => {
|
||||
try {
|
||||
@@ -31,6 +32,7 @@ export const login = async ({
|
||||
window.location = getLoginRedirectURL({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
redirectUrl,
|
||||
user: response.data.data,
|
||||
});
|
||||
return null;
|
||||
|
||||
@@ -40,8 +40,16 @@ export const getCredentialsFromEmail = email => {
|
||||
export const getLoginRedirectURL = ({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
redirectUrl,
|
||||
user,
|
||||
}) => {
|
||||
if (redirectUrl) {
|
||||
const { accounts = [], account_id = null } = user || {};
|
||||
const accountId = account_id || accounts[0]?.id;
|
||||
if (accountId) {
|
||||
return frontendURL(`accounts/${accountId}/${redirectUrl}`);
|
||||
}
|
||||
}
|
||||
const accountPath = getSSOAccountPath({ ssoAccountId, user });
|
||||
if (accountPath) {
|
||||
if (ssoConversationId) {
|
||||
|
||||
@@ -29,7 +29,11 @@ export const validateRouteAccess = (to, next, chatwootConfig = {}) => {
|
||||
// Redirect to dashboard if a cookie is present, the cookie
|
||||
// cleanup and token validation happens in the application pack.
|
||||
if (hasAuthCookie()) {
|
||||
replaceRouteWithReload(DEFAULT_REDIRECT_URL);
|
||||
const { redirect_url: redirectUrl } = to.query || {};
|
||||
const redirectTarget = redirectUrl
|
||||
? `${DEFAULT_REDIRECT_URL}?redirect_url=${encodeURIComponent(redirectUrl)}`
|
||||
: DEFAULT_REDIRECT_URL;
|
||||
replaceRouteWithReload(redirectTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ export default {
|
||||
ssoConversationId: { type: String, default: '' },
|
||||
email: { type: String, default: '' },
|
||||
authError: { type: String, default: '' },
|
||||
redirectUrl: { type: String, default: '' },
|
||||
},
|
||||
setup() {
|
||||
const { replaceInstallationName } = useBranding();
|
||||
@@ -169,6 +170,7 @@ export default {
|
||||
sso_auth_token: this.ssoAuthToken,
|
||||
ssoAccountId: this.ssoAccountId,
|
||||
ssoConversationId: this.ssoConversationId,
|
||||
redirectUrl: this.redirectUrl,
|
||||
};
|
||||
|
||||
login(credentials)
|
||||
|
||||
@@ -19,6 +19,7 @@ export default [
|
||||
ssoAccountId: route.query.sso_account_id,
|
||||
ssoConversationId: route.query.sso_conversation_id,
|
||||
authError: route.query.error,
|
||||
redirectUrl: route.query.redirect_url,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user