| @@ -70,11 +70,6 @@ export default async function middleware( | |||||
| response.cookies.set("i18next", langPref); | response.cookies.set("i18next", langPref); | ||||
| return response; | return response; | ||||
| } | } | ||||
| let abilities: string[] = [] | |||||
| if (token) { | |||||
| abilities = (token.abilities as ability[]).map((item: ability) => item.actionSubjectCombo); | |||||
| } | |||||
| const authMiddleware = withAuth({ | const authMiddleware = withAuth({ | ||||
| pages: authOptions.pages, | pages: authOptions.pages, | ||||
| @@ -84,6 +79,7 @@ export default async function middleware( | |||||
| if (!Boolean(token)) { | if (!Boolean(token)) { | ||||
| return Boolean(token) | return Boolean(token) | ||||
| } | } | ||||
| const abilities = (token!.abilities as ability[]).map((item: ability) => item.actionSubjectCombo); | |||||
| if (req.nextUrl.pathname.startsWith('/settings')) { | if (req.nextUrl.pathname.startsWith('/settings')) { | ||||
| isAuth = [VIEW_MASTERDATA, MAINTAIN_MASTERDATA].some((ability) => abilities.includes(ability)); | isAuth = [VIEW_MASTERDATA, MAINTAIN_MASTERDATA].some((ability) => abilities.includes(ability)); | ||||
| } | } | ||||