mirror of
https://github.com/strapi/strapi.git
synced 2025-07-12 03:22:59 +00:00

* add possibility to use strapi on a non-root base url path * fix documentation password form * use server.url and admin.url in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update doc proxy Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * move server.url location in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * add possibility to put relative urls Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * allow '/' as an admin url + refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update yarn.lock Signed-off-by: Pierre Noël <petersg83@gmail.com> * refacto Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove default proxy option Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> * fix github provider Signed-off-by: Pierre Noël <petersg83@gmail.com> * fix github login Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove files that should be here Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> Co-authored-by: Pierre Noël <pierre.noel@strapi.io> Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com>
32 lines
784 B
JavaScript
Executable File
32 lines
784 B
JavaScript
Executable File
module.exports = async (ctx, next) => {
|
|
const pluginStore = strapi.store({
|
|
environment: '',
|
|
type: 'plugin',
|
|
name: 'documentation',
|
|
});
|
|
const config = await pluginStore.get({ key: 'config' });
|
|
|
|
if (!config.restrictedAccess) {
|
|
return await next();
|
|
}
|
|
|
|
if (!ctx.session.documentation) {
|
|
const querystring = ctx.querystring ? `?${ctx.querystring}` : '';
|
|
|
|
return ctx.redirect(
|
|
`${strapi.config.server.url}${strapi.plugins.documentation.config['x-strapi-config'].path}/login${querystring}`
|
|
);
|
|
}
|
|
const isValid = strapi.plugins['users-permissions'].services.user.validatePassword(
|
|
ctx.session.documentation,
|
|
config.password
|
|
);
|
|
|
|
if (!isValid) {
|
|
ctx.session.documentation = null;
|
|
}
|
|
|
|
// Execute the action.
|
|
await next();
|
|
};
|