chore: Allow super admin to suspend an account (#5174)

This commit is contained in:
Pranav Raj S 2022-08-03 11:40:03 +05:30 committed by GitHub
parent 4152883f38
commit e0cebfaa1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 259 additions and 23 deletions

View file

@ -6,6 +6,7 @@ import authRoute from './auth/auth.routes';
import dashboard from './dashboard/dashboard.routes';
import login from './login/login.routes';
import store from '../store';
import { validateLoggedInRoutes } from '../helper/routeHelpers';
const routes = [...login.routes, ...dashboard.routes, ...authRoute.routes];
@ -14,11 +15,6 @@ window.roleWiseRoutes = {
administrator: [],
};
const getUserRole = ({ accounts } = {}, accountId) => {
const currentAccount = accounts.find(account => account.id === accountId);
return currentAccount ? currentAccount.role : null;
};
// generateRoleWiseRoute - updates window object with agent/admin route
const generateRoleWiseRoute = route => {
route.forEach(element => {
@ -47,10 +43,6 @@ const authIgnoreRoutes = [
'auth_password_edit',
];
function routeIsAccessibleFor(route, role) {
return window.roleWiseRoutes[role].includes(route);
}
const routeValidators = [
{
protected: false,
@ -68,12 +60,8 @@ const routeValidators = [
{
protected: true,
loggedIn: true,
handler: (to, getters) => {
const user = getters.getCurrentUser;
const userRole = getUserRole(user, Number(to.params.accountId));
const isAccessible = routeIsAccessibleFor(to.name, userRole);
return isAccessible ? null : `accounts/${to.params.accountId}/dashboard`;
},
handler: (to, getters) =>
validateLoggedInRoutes(to, getters.getCurrentUser, window.roleWiseRoutes),
},
{
protected: false,