25 lines
616 B
JavaScript
Raw Normal View History

'use strict';
module.exports = async (ctx, next) => {
const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
const config = await pluginStore.get({ key: 'config' });
if (!config.restrictedAccess) {
return next();
}
if (!ctx.session.documentation || !ctx.session.documentation.logged) {
const querystring = ctx.querystring ? `?${ctx.querystring}` : '';
return ctx.redirect(
2021-07-20 12:12:30 +02:00
`${strapi.config.server.url}${
2021-08-06 18:09:49 +02:00
strapi.config.get('plugin.documentation.x-strapi-config').path
2021-07-20 12:12:30 +02:00
}/login${querystring}`
);
}
// Execute the action.
2021-09-02 11:25:24 +02:00
return next();
};