Skip to content

Commit c012758

Browse files
User: Hide Registration link and button based on allow_registration setting - refs BT#22225
1 parent a23e428 commit c012758

File tree

5 files changed

+96
-60
lines changed

5 files changed

+96
-60
lines changed

assets/vue/components/Login.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
/>
5050

5151
<a
52+
v-if="allowRegistration"
5253
v-t="'Register oneself'"
5354
class="btn btn--primary-outline"
5455
href="/main/auth/inscription.php"
@@ -72,16 +73,19 @@
7273
</template>
7374

7475
<script setup>
75-
import { ref } from "vue"
76+
import { ref, computed } from "vue"
7677
import Button from "primevue/button"
7778
import InputText from "primevue/inputtext"
7879
import Password from "primevue/password"
7980
import InputSwitch from "primevue/inputswitch"
8081
import { useI18n } from "vue-i18n"
8182
import { useLogin } from "../composables/auth/login"
8283
import ExternalLoginButtons from "./login/LoginExternalButtons.vue"
84+
import { usePlatformConfig } from "../store/platformConfig"
8385
8486
const { t } = useI18n()
87+
const platformConfigStore = usePlatformConfig()
88+
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))
8589
8690
const { redirectNotAuthenticated, performLogin, isLoading } = useLogin()
8791

assets/vue/components/layout/TopbarNotLoggedIn.vue

+39-27
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useI18n } from "vue-i18n"
1515
import { useRouter } from "vue-router"
1616
import { useLocale } from "../../composables/locale"
1717
import PlatformLogo from "./PlatformLogo.vue"
18+
import {usePlatformConfig} from "../../store/platformConfig"
1819
1920
const { t } = useI18n()
2021
const router = useRouter()
@@ -27,31 +28,42 @@ const languageItems = languageList.map((language) => ({
2728
command: (event) => reloadWithLocale(event.item.isoCode),
2829
}))
2930
30-
const menuItems = computed(() => [
31-
{
32-
label: t("Home"),
33-
url: router.resolve({ name: "Index" }).href,
34-
},
35-
{
36-
label: t("FAQ"),
37-
url: router.resolve({ name: "Faq" }).href,
38-
},
39-
{
40-
label: t("Registration"),
41-
url: "/main/auth/inscription.php",
42-
},
43-
{
44-
label: t("Demo"),
45-
url: router.resolve({ name: "Demo" }).href,
46-
},
47-
{
48-
label: t("Contact"),
49-
url: "/contact",
50-
},
51-
{
52-
key: "language_selector",
53-
label: currentLanguageFromList.originalName,
54-
items: languageItems,
55-
},
56-
])
31+
const platformConfigStore = usePlatformConfig()
32+
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))
33+
34+
const menuItems = computed(() => {
35+
const items = [
36+
{
37+
label: t("Home"),
38+
url: router.resolve({ name: "Index" }).href,
39+
},
40+
{
41+
label: t("FAQ"),
42+
url: router.resolve({ name: "Faq" }).href,
43+
},
44+
{
45+
label: t("Demo"),
46+
url: router.resolve({ name: "Demo" }).href,
47+
},
48+
{
49+
label: t("Contact"),
50+
url: "/contact",
51+
},
52+
{
53+
key: "language_selector",
54+
label: currentLanguageFromList.originalName,
55+
items: languageItems,
56+
},
57+
]
58+
59+
if (allowRegistration.value) {
60+
items.splice(2, 0, {
61+
label: t("Registration"),
62+
url: "/main/auth/inscription.php",
63+
})
64+
}
65+
66+
console.log("Menu Items:", items)
67+
return items
68+
})
5769
</script>

src/CoreBundle/Controller/PlatformConfigurationController.php

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function list(SettingsManager $settingsManager): Response
4545
'visual_theme' => $this->themeHelper->getVisualTheme(),
4646
'external_authentication' => $this->authenticationConfigHelper->getEnabledProviders(),
4747
];
48+
49+
$configuration['settings']['registration.allow_registration'] = $settingsManager->getSetting('registration.allow_registration', true);
50+
4851
$variables = [];
4952

5053
if ($this->isGranted('ROLE_USER')) {

var/vue_templates/components/SidebarLogin.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script setup>
2-
import { ref } from "vue"
2+
import {computed, ref} from "vue"
33
import { useI18n } from "vue-i18n"
44
import InputText from "primevue/inputtext"
55
import Password from "primevue/password"
66
import Button from "primevue/button"
77
import InputSwitch from "primevue/inputswitch"
88
import { useLogin } from "../../../assets/vue/composables/auth/login"
9+
import {usePlatformConfig} from "../../../assets/vue/store/platformConfig"
910
1011
const { t } = useI18n()
1112
@@ -15,6 +16,9 @@ const login = ref("")
1516
const password = ref("")
1617
const remember = ref(false)
1718
19+
const platformConfigStore = usePlatformConfig()
20+
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))
21+
1822
function onSubmitLoginForm() {
1923
performLogin({
2024
login: login.value,
@@ -74,6 +78,7 @@ function onSubmitLoginForm() {
7478
/>
7579

7680
<a
81+
v-if="allowRegistration"
7782
v-t="'Register oneself'"
7883
class="btn btn--primary-outline"
7984
href="/main/auth/inscription.php"

var/vue_templates/components/layout/SidebarNotLoggedIn.vue

+43-31
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Dropdown from "primevue/dropdown"
77
import SidebarLogin from "../SidebarLogin.vue"
88
import PageList from "../../../../assets/vue/components/page/PageList.vue"
99
import { useLocale } from "../../../../assets/vue/composables/locale"
10+
import { usePlatformConfig } from "../../../../assets/vue/store/platformConfig"
1011
1112
const { t } = useI18n()
1213
const router = useRouter()
@@ -22,37 +23,48 @@ const languageItems = languageList.map((language) => ({
2223
isoCode: language.isocode,
2324
}))
2425
25-
const menuItems = computed(() => [
26-
{
27-
label: t("Home"),
28-
url: router.resolve({ name: "Index" }).href,
29-
},
30-
{
31-
id: "login-header-item",
32-
label: t("Login"),
33-
items: [
34-
{
35-
id: "login-form-item",
36-
},
37-
],
38-
},
39-
{
40-
label: t("Registration"),
41-
url: "/main/auth/inscription.php",
42-
},
43-
{
44-
label: t("Demo"),
45-
url: router.resolve({ name: "Demo" }).href,
46-
},
47-
{
48-
label: t("FAQ"),
49-
url: router.resolve({ name: "Faq" }).href,
50-
},
51-
{
52-
label: t("Contact"),
53-
url: "/contact",
54-
},
55-
])
26+
const platformConfigStore = usePlatformConfig()
27+
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))
28+
29+
30+
const menuItems = computed(() => {
31+
const items = [
32+
{
33+
label: t("Home"),
34+
url: router.resolve({ name: "Index" }).href,
35+
},
36+
{
37+
id: "login-header-item",
38+
label: t("Login"),
39+
items: [
40+
{
41+
id: "login-form-item",
42+
},
43+
],
44+
},
45+
{
46+
label: t("Demo"),
47+
url: router.resolve({ name: "Demo" }).href,
48+
},
49+
{
50+
label: t("FAQ"),
51+
url: router.resolve({ name: "Faq" }).href,
52+
},
53+
{
54+
label: t("Contact"),
55+
url: "/contact",
56+
},
57+
]
58+
59+
if (allowRegistration.value) {
60+
items.splice(2, 0, {
61+
label: t("Registration"),
62+
url: "/main/auth/inscription.php",
63+
})
64+
}
65+
66+
return items
67+
})
5668
5769
const sidebarIsOpen = ref(window.localStorage.getItem("sidebarIsOpen") === "true")
5870

0 commit comments

Comments
 (0)