Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FWF:3560[Bugfix] Fixed Admin Login showing Forms page #2182

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions forms-flow-web/src/components/PrivateRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ const PrivateRoute = React.memo((props) => {
const viewTasks = userRoles.includes("view_tasks");
const manageTasks = userRoles.includes("manage_tasks");
const viewDashboards = userRoles.includes("view_dashbaords");



const isAdmin = userRoles.includes("admin");
const isCreateSubmissions = userRoles?.includes("create_submissions");
const isViewDesigns = userRoles?.includes("view_designs");
fahad-aot marked this conversation as resolved.
Show resolved Hide resolved
const isCreateDesigns = userRoles?.includes("create_designs");

const authenticate = (instance, store) => {
setKcInstance(instance);
Expand Down Expand Up @@ -298,18 +299,21 @@ const PrivateRoute = React.memo((props) => {
component={ServiceFlow}
/>
)}

<Route exact path={`${redirecUrl}admin`} />
fahad-aot marked this conversation as resolved.
Show resolved Hide resolved
<Route exact path={BASE_ROUTE}>
{userRoles.length && (
<Redirect
to={
viewTasks || manageTasks
? `${redirecUrl}task`
: `${redirecUrl}form`
}
/>
)}

<Redirect
to={
(viewTasks || manageTasks)
? `${redirecUrl}task`
: ( isCreateSubmissions || isCreateDesigns || isViewDesigns)
? `${redirecUrl}form`
: isAdmin
? `${redirecUrl}admin`
: `${BASE_ROUTE}processes`
}
/>
)}
</Route>
<Route path="/404" exact={true} component={NotFound} />
<Redirect from="*" to="/404" />
Expand Down
Loading