From b000c9087e826c0491b6b114473fe9818a2bbce8 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 5 Apr 2023 11:45:45 +0000 Subject: [PATCH] Bug 33408: Prevent access to erm module by URL if sys pref is disabled Signed-off-by: Pedro Amorim --- .../prog/js/vue/components/ERM/Main.vue | 13 ++++++------- t/cypress/integration/ERM/Agreements_spec.ts | 7 ++----- t/cypress/integration/ERM/Dialog_spec.ts | 7 ++----- t/cypress/integration/ERM/Licenses_spec.ts | 7 ++----- t/cypress/integration/ERM/Packages_spec.ts | 7 ++----- t/cypress/integration/ERM/Titles_spec.ts | 7 ++----- 6 files changed, 16 insertions(+), 32 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue index 7267659e0d1..5c97cda1272 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue @@ -214,15 +214,18 @@ export default { error => {} ) ) - return Promise.all(promises) + return Promise.all(promises).then(values => { + this.loaded() + this.initialized = true + }) } const sysprefs_client = APIClient.sysprefs sysprefs_client.sysprefs .get("ERMModule") .then(value => { - this.ERMModule = value - if (!this.ERMModule) { + this.ERMModule = value.value + if (this.ERMModule == 0) { this.loaded() return this.setError( this.$__( @@ -233,10 +236,6 @@ export default { } return fetch_config() }) - .then(() => { - this.loaded() - this.initialized = true - }) }, components: { Breadcrumb, diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts index b9319278583..cd7689c31e2 100644 --- a/t/cypress/integration/ERM/Agreements_spec.ts +++ b/t/cypress/integration/ERM/Agreements_spec.ts @@ -117,14 +117,11 @@ function get_licenses_to_relate() { } describe("Agreement CRUD operations", () => { - before(() => { - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); - }); - beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); it("List agreements", () => { diff --git a/t/cypress/integration/ERM/Dialog_spec.ts b/t/cypress/integration/ERM/Dialog_spec.ts index dc85f035d24..79665cb7a94 100644 --- a/t/cypress/integration/ERM/Dialog_spec.ts +++ b/t/cypress/integration/ERM/Dialog_spec.ts @@ -22,14 +22,11 @@ function get_package() { } describe("Dialog operations", () => { - before(() => { - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); - }); - beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); it("There are no ... defined", () => { diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts index 78d1390c029..5ba6dfd231c 100644 --- a/t/cypress/integration/ERM/Licenses_spec.ts +++ b/t/cypress/integration/ERM/Licenses_spec.ts @@ -33,14 +33,11 @@ function get_license() { } describe("License CRUD operations", () => { - before(() => { - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); - }); - beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); it("List license", () => { diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts index 647c30d19eb..4e0308d6a25 100644 --- a/t/cypress/integration/ERM/Packages_spec.ts +++ b/t/cypress/integration/ERM/Packages_spec.ts @@ -24,14 +24,11 @@ function get_package() { } describe("Package CRUD operations", () => { - before(() => { - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); - }); - beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); it("List package", () => { diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts index 06724aa4d8c..56aa71dcf3d 100644 --- a/t/cypress/integration/ERM/Titles_spec.ts +++ b/t/cypress/integration/ERM/Titles_spec.ts @@ -18,14 +18,11 @@ function get_packages_to_relate() { } describe("Title CRUD operations", () => { - before(() => { - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); - cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); - }); - beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); it("Import titles", () => { -- 2.30.2