chore: Pass sso_account_id to select the account during SSO Login (#4103)
This commit is contained in:
@@ -5,6 +5,7 @@ import login from './login/login.routes';
|
||||
import dashboard from './dashboard/dashboard.routes';
|
||||
import authRoute from './auth/auth.routes';
|
||||
import { frontendURL } from '../helper/URLHelper';
|
||||
import { clearBrowserSessionCookies } from '../store/utils/api';
|
||||
|
||||
const routes = [
|
||||
...login.routes,
|
||||
@@ -101,6 +102,13 @@ export const validateAuthenticateRoutePermission = (to, from, next) => {
|
||||
return nextRoute ? next(frontendURL(nextRoute)) : next();
|
||||
};
|
||||
|
||||
const validateSSOLoginParams = to => {
|
||||
const isLoginRoute = to.name === 'login';
|
||||
const { email, sso_auth_token: ssoAuthToken } = to.query || {};
|
||||
const hasValidSSOParams = email && ssoAuthToken;
|
||||
return isLoginRoute && hasValidSSOParams;
|
||||
};
|
||||
|
||||
const validateRouteAccess = (to, from, next) => {
|
||||
if (
|
||||
window.chatwootConfig.signupEnabled !== 'true' &&
|
||||
@@ -111,6 +119,11 @@ const validateRouteAccess = (to, from, next) => {
|
||||
next(frontendURL(`accounts/${user.account_id}/dashboard`));
|
||||
}
|
||||
|
||||
if (validateSSOLoginParams(to)) {
|
||||
clearBrowserSessionCookies();
|
||||
return next();
|
||||
}
|
||||
|
||||
if (authIgnoreRoutes.includes(to.name)) {
|
||||
return next();
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ export default {
|
||||
mixins: [globalConfigMixin],
|
||||
props: {
|
||||
ssoAuthToken: { type: String, default: '' },
|
||||
ssoAccountId: { type: String, default: '' },
|
||||
redirectUrl: { type: String, default: '' },
|
||||
config: { type: String, default: '' },
|
||||
email: { type: String, default: '' },
|
||||
@@ -138,6 +139,7 @@ export default {
|
||||
: this.credentials.email,
|
||||
password: this.credentials.password,
|
||||
sso_auth_token: this.ssoAuthToken,
|
||||
ssoAccountId: this.ssoAccountId,
|
||||
};
|
||||
this.$store
|
||||
.dispatch('login', credentials)
|
||||
|
||||
@@ -12,6 +12,7 @@ export default {
|
||||
email: route.query.email,
|
||||
ssoAuthToken: route.query.sso_auth_token,
|
||||
redirectUrl: route.query.route_url,
|
||||
ssoAccountId: route.query.sso_account_id,
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user