/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/plugins/documentation/server/src/middlewares/restrict-access.ts
23 строки
676 B
Alexandre Bodin
chore: migrate doc plugin to ts
21 мар 2024, 20:20
21 мар 2024, 20:20
eedd4c9
Код
Авторство
О чём код?
import type Koa from 'koa'; import type {} from 'koa-session'; import type { Config } from '../types'; export default async (ctx: Koa.Context, next: Koa.Next) => { const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' }); const config = (await pluginStore.get({ key: 'config' })) as Config; if (!config.restrictedAccess) { return next(); } if (!ctx.session || !ctx.session.documentation || !ctx.session.documentation.logged) { const querystring = ctx.querystring ? `?${ctx.querystring}` : ''; return ctx.redirect(`${strapi.config.server.url}/documentation/login${querystring}`); } // Execute the action. return next(); };