generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/kob fix authentication and redirect admin (#51)
* Fix admin routing and redirect for non admins * Update core.router.ts * Update main.ts * Update main.ts * Update main.ts * Update core.router.ts * Update the-drawer-main-store.module.ts * Update the-admin-overview.vue * Update u-finder.routes.ts * Change admin view based on type * Fix typescript errors * Add Admin roles and improvements * Add missing route to menu for department admin * clean up * Fix theme on redirect --------- Co-authored-by: Thomas Fink <[email protected]>
- Loading branch information
1 parent
d298770
commit 3c5e65a
Showing
30 changed files
with
811 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,7 @@ dist/ | |
nbdist/ | ||
.nb-gradle/ | ||
|
||
# Intellij | ||
.run/kobit-frontend.run.xml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,110 @@ | ||
import Vue from "vue"; | ||
import Router from "vue-router"; | ||
// Add this import at the top of core.router.ts | ||
import vuetify, { adminTheme, kobitTheme } from "@/core/plugins/vuetify"; | ||
import Vue from 'vue'; | ||
import Router from 'vue-router'; | ||
import vuetify, { adminTheme, kobitTheme } from '@/core/plugins/vuetify'; | ||
|
||
import {theMainRoutes} from "@/features/the-main/the-main.routes"; | ||
import {erfahreMehrRoutes} from "@/features/the-additional/the-additional.routes"; | ||
import { | ||
conflictPreventionRoutes | ||
} from "@/features/the-additional/features/the-conflict-prevention/the-conflict-prevention.routes"; | ||
import {downloadsRoutes} from "@/features/the-additional/features/the-downloads/the-downloads.routes"; | ||
import {faqRoutes} from "@/features/the-additional/features/the-faq/the-faq.routes"; | ||
import {glossarRoutes} from "@/features/the-additional/features/the-glossar/the-glossar.routes"; | ||
import { | ||
leadershipCooperationRoutes | ||
} from "@/features/the-additional/features/the-leadership-cooperation/the-leadership-cooperation.routes"; | ||
import {dvFairRoutes} from "@/features/the-additional/features/the-dv-fair/the-dv-fair.routes"; | ||
import { | ||
escalationStepsRoutes | ||
} from "@/features/the-additional/features/the-escalation-steps/the-escalation-steps.routes"; | ||
import { | ||
theAnlaufstellenRoutes | ||
} from "@/features/the-unterstuetzungsfinder/features/the-contact-points/the-contact-points.routes"; | ||
import {theAngeboteRoutes} from "@/features/the-angebote/the-angebote.routes"; | ||
import {theUnterstuetzungsfinderRoutes} from "@/features/the-unterstuetzungsfinder/the-unterstuetzungsfinder.routes"; | ||
import { | ||
theAnlaufstellenDetailsRoutes | ||
} from "@/features/the-unterstuetzungsfinder/features/the-contact-points/the-contact-points-details.routes"; | ||
import {adminUFinderRoutes} from "@/features/admin/components/u-finder/u-finder.routes"; | ||
import { theMainRoutes } from '@/features/the-main/the-main.routes'; | ||
import { erfahreMehrRoutes } from '@/features/the-additional/the-additional.routes'; | ||
import { conflictPreventionRoutes } from '@/features/the-additional/features/the-conflict-prevention/the-conflict-prevention.routes'; | ||
import { downloadsRoutes } from '@/features/the-additional/features/the-downloads/the-downloads.routes'; | ||
import { faqRoutes } from '@/features/the-additional/features/the-faq/the-faq.routes'; | ||
import { glossarRoutes } from '@/features/the-additional/features/the-glossar/the-glossar.routes'; | ||
import { leadershipCooperationRoutes } from '@/features/the-additional/features/the-leadership-cooperation/the-leadership-cooperation.routes'; | ||
import { dvFairRoutes } from '@/features/the-additional/features/the-dv-fair/the-dv-fair.routes'; | ||
import { escalationStepsRoutes } from '@/features/the-additional/features/the-escalation-steps/the-escalation-steps.routes'; | ||
import { theAnlaufstellenRoutes } from '@/features/the-unterstuetzungsfinder/features/the-contact-points/the-contact-points.routes'; | ||
import { theAngeboteRoutes } from '@/features/the-angebote/the-angebote.routes'; | ||
import { theUnterstuetzungsfinderRoutes } from '@/features/the-unterstuetzungsfinder/the-unterstuetzungsfinder.routes'; | ||
import { theAnlaufstellenDetailsRoutes } from '@/features/the-unterstuetzungsfinder/features/the-contact-points/the-contact-points-details.routes'; | ||
|
||
import {adminRoutes} from "@/features/admin/the-admin-routes"; | ||
import {adminContactPointsRoutes} from "@/features/admin/features/the-contact-points/the-contact-points-routes"; | ||
import {adminExperienceMoreRoutes} from "@/features/admin/features/the-additional/the-additional-overview-routes"; | ||
import { | ||
adminConflictPreventionRoutes | ||
} from "@/features/admin/features/the-additional/features/the-conflict-prevention/the-conflict-prevention.routes"; | ||
import { | ||
adminDownloadsRoutes | ||
} from "@/features/admin/features/the-additional/features/the-downloads/the-downloads.routes"; | ||
import { | ||
adminFaqRoutes | ||
} from "@/features/admin/features/the-additional/features/the-faq/the-faq.routes"; | ||
import { | ||
adminGlossarRoutes | ||
} from "@/features/admin/features/the-additional/features/the-glossar/the-glossar.routes"; | ||
import { | ||
adminLeadershipCooperationRoutes | ||
} from "@/features/admin/features/the-additional/features/the-leadership-cooperation/the-leadership-cooperation.routes"; | ||
import { adminRoutes } from '@/features/admin/the-admin-routes'; | ||
import { adminContactPointsRoutes } from '@/features/admin/features/the-contact-points/the-contact-points-routes'; | ||
import { adminAdditionalRoutes } from '@/features/admin/features/the-additional/the-additional-overview-routes'; | ||
import { adminConflictPreventionRoutes } from '@/features/admin/features/the-additional/features/the-conflict-prevention/the-conflict-prevention.routes'; | ||
import { adminDownloadsRoutes } from '@/features/admin/features/the-additional/features/the-downloads/the-downloads.routes'; | ||
import { adminFaqRoutes } from '@/features/admin/features/the-additional/features/the-faq/the-faq.routes'; | ||
import { adminGlossarRoutes } from '@/features/admin/features/the-additional/features/the-glossar/the-glossar.routes'; | ||
import { adminLeadershipCooperationRoutes } from '@/features/admin/features/the-additional/features/the-leadership-cooperation/the-leadership-cooperation.routes'; | ||
import { adminUnterstuetzungsfinderRoutes } from '@/features/admin/components/u-finder/u-finder.routes'; | ||
|
||
Vue.use(Router); | ||
import { getAdminUserInfo } from '@/features/admin/components/userinformation/api/AdminInfoClient'; | ||
|
||
/* | ||
* Preventing "NavigationDuplicated" errors in console in Vue-router >= 3.1.0 | ||
* https://github.com/vuejs/vue-router/issues/2881#issuecomment-520554378 | ||
* */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const routerMethods = ['push', 'replace']; | ||
routerMethods.forEach((method: string) => { | ||
const originalCall = (Router.prototype as any)[method]; | ||
(Router.prototype as any)[method] = function (location: any, onResolve: any, onReject: any): Promise<any> { | ||
if (onResolve || onReject) { | ||
return originalCall.call(this, location, onResolve, onReject); | ||
} | ||
return (originalCall.call(this, location) as any).catch((err: any) => err); | ||
}; | ||
}); | ||
/* eslint-enable @typescript-eslint/no-explicit-any */ | ||
Vue.use(Router); | ||
|
||
const baseRoutes = [ | ||
theMainRoutes, | ||
theUnterstuetzungsfinderRoutes, | ||
erfahreMehrRoutes, | ||
conflictPreventionRoutes, | ||
downloadsRoutes, | ||
faqRoutes, | ||
glossarRoutes, | ||
leadershipCooperationRoutes, | ||
dvFairRoutes, | ||
escalationStepsRoutes, | ||
theAnlaufstellenRoutes, | ||
theAnlaufstellenDetailsRoutes, | ||
theAngeboteRoutes | ||
]; | ||
|
||
const router = new Router({ | ||
base: process.env.BASE_URL, | ||
routes: [ | ||
theMainRoutes, | ||
theUnterstuetzungsfinderRoutes, | ||
erfahreMehrRoutes, | ||
conflictPreventionRoutes, | ||
downloadsRoutes, | ||
faqRoutes, | ||
glossarRoutes, | ||
leadershipCooperationRoutes, | ||
dvFairRoutes, | ||
escalationStepsRoutes, | ||
theAnlaufstellenRoutes, | ||
theAnlaufstellenDetailsRoutes, | ||
theAngeboteRoutes, | ||
adminRoutes, | ||
adminContactPointsRoutes, | ||
adminExperienceMoreRoutes, | ||
adminConflictPreventionRoutes, | ||
adminDownloadsRoutes, | ||
adminFaqRoutes, | ||
adminGlossarRoutes, | ||
adminLeadershipCooperationRoutes, | ||
adminUFinderRoutes | ||
] | ||
routes: baseRoutes | ||
}); | ||
|
||
router.beforeEach((to, _, next) => { | ||
if (to.path === '/admin' || to.path.startsWith('/admin/')) { | ||
vuetify.framework.theme.themes.light = adminTheme.themes.light; | ||
vuetify.framework.theme.themes.dark = adminTheme.themes.dark; | ||
let adminRoutesAdded = false; | ||
|
||
router.beforeEach(async (to, from, next) => { | ||
if (!adminRoutesAdded && to.path.startsWith('/admin')) { | ||
try { | ||
const adminUserInfo = await getAdminUserInfo(); | ||
|
||
let adminRoutesToAdd: string | any[] = []; | ||
|
||
if (adminUserInfo.isCentralAdmin) { | ||
adminRoutesToAdd = [ | ||
...adminRoutesToAdd, | ||
adminRoutes, | ||
adminContactPointsRoutes, | ||
adminAdditionalRoutes, | ||
adminConflictPreventionRoutes, | ||
adminDownloadsRoutes, | ||
adminFaqRoutes, | ||
adminGlossarRoutes, | ||
adminLeadershipCooperationRoutes, | ||
adminUnterstuetzungsfinderRoutes | ||
]; | ||
} else if (adminUserInfo.isDepartmentAdmin) { | ||
adminRoutesToAdd = [ | ||
...adminRoutesToAdd, | ||
adminRoutes, | ||
adminContactPointsRoutes, | ||
adminUnterstuetzungsfinderRoutes | ||
]; | ||
} | ||
|
||
if (adminRoutesToAdd.length > 0) { | ||
router.addRoutes(adminRoutesToAdd); | ||
adminRoutesAdded = true; | ||
|
||
vuetify.framework.theme.themes.light = adminTheme.themes.light; | ||
vuetify.framework.theme.themes.dark = adminTheme.themes.dark; | ||
|
||
next({ path: to.path, query: to.query, replace: true }); | ||
} else { | ||
vuetify.framework.theme.themes.light = kobitTheme.themes.light; | ||
vuetify.framework.theme.themes.dark = kobitTheme.themes.dark; | ||
next({ path: '/' }); | ||
} | ||
} catch (error) { | ||
vuetify.framework.theme.themes.light = kobitTheme.themes.light; | ||
vuetify.framework.theme.themes.dark = kobitTheme.themes.dark; | ||
next({ path: '/' }); | ||
} | ||
} else { | ||
vuetify.framework.theme.themes.light = kobitTheme.themes.light; | ||
vuetify.framework.theme.themes.dark = kobitTheme.themes.dark; | ||
next(); | ||
} | ||
next(); | ||
}); | ||
|
||
|
||
export default router; | ||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
frontend/src/features/admin/components/u-finder/u-finder.routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import SupportFinderAdmin from "@/features/admin/components/u-finder/SupportFinderAdmin.vue"; | ||
|
||
export const THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_PATH = "/admin/unterstuetzungsfinder"; | ||
export const THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_NAME = "Unterstützungsfinder - Admin Bereich"; | ||
export const THE_UNTERSTUETZUNGSFINDER_ROUTE_PATH = "/admin/unterstuetzungsfinder"; | ||
export const THE_UNTERSTUETZUNGSFINDER_ROUTE_NAME = "Unterstützungsfinder bearbeiten"; | ||
export const THE_UNTERSTUETZUNGSFINDER_ROUTE_META_ICON = "mdi-arrow-decision"; | ||
export const THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_META_INFO_TEXT = `Hier können sie den einzelnen Pfaden des Unterstützungsfinder entsprechende Anlaufstellen zuordnen. Dafür müssen die einzelnen Pfade genau wie im "normalen" Unterstützungsfinder durchlaufen werden.`; | ||
export const THE_UNTERSTUETZUNGSFINDER_ROUTE_META_INFO_TEXT = `Hier können sie den einzelnen Pfaden des Unterstützungsfinder entsprechende Anlaufstellen zuordnen. Dafür müssen die einzelnen Pfade genau wie im "normalen" Unterstützungsfinder durchlaufen werden.`; | ||
|
||
export const adminUFinderRoutes = { | ||
name: THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_NAME, | ||
path: THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_PATH, | ||
export const adminUnterstuetzungsfinderRoutes = { | ||
name: THE_UNTERSTUETZUNGSFINDER_ROUTE_NAME, | ||
path: THE_UNTERSTUETZUNGSFINDER_ROUTE_PATH, | ||
component: SupportFinderAdmin, | ||
meta: { | ||
icon: THE_UNTERSTUETZUNGSFINDER_ROUTE_META_ICON, | ||
infoText: THE_UNTERSTUETZUNGSFINDER_ADMIN_ROUTE_META_INFO_TEXT | ||
infoText: THE_UNTERSTUETZUNGSFINDER_ROUTE_META_INFO_TEXT | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.