chore: Pass sso_account_id to select the account during SSO Login (#4103)
This commit is contained in:
parent
11adfd2384
commit
9583a2dbad
8 changed files with 61 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue