Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User: Hide Registration link and button based on allow_registration setting - refs BT#22225 #5942

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/vue/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
/>

<a
v-if="allowRegistration"
v-t="'Register oneself'"
class="btn btn--primary-outline"
href="/main/auth/inscription.php"
Expand All @@ -72,16 +73,19 @@
</template>

<script setup>
import { ref } from "vue"
import { ref, computed } from "vue"
import Button from "primevue/button"
import InputText from "primevue/inputtext"
import Password from "primevue/password"
import InputSwitch from "primevue/inputswitch"
import { useI18n } from "vue-i18n"
import { useLogin } from "../composables/auth/login"
import ExternalLoginButtons from "./login/LoginExternalButtons.vue"
import { usePlatformConfig } from "../store/platformConfig"

const { t } = useI18n()
const platformConfigStore = usePlatformConfig()
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))

const { redirectNotAuthenticated, performLogin, isLoading } = useLogin()

Expand Down
66 changes: 39 additions & 27 deletions assets/vue/components/layout/TopbarNotLoggedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useI18n } from "vue-i18n"
import { useRouter } from "vue-router"
import { useLocale } from "../../composables/locale"
import PlatformLogo from "./PlatformLogo.vue"
import {usePlatformConfig} from "../../store/platformConfig"

const { t } = useI18n()
const router = useRouter()
Expand All @@ -27,31 +28,42 @@ const languageItems = languageList.map((language) => ({
command: (event) => reloadWithLocale(event.item.isoCode),
}))

const menuItems = computed(() => [
{
label: t("Home"),
url: router.resolve({ name: "Index" }).href,
},
{
label: t("FAQ"),
url: router.resolve({ name: "Faq" }).href,
},
{
label: t("Registration"),
url: "/main/auth/inscription.php",
},
{
label: t("Demo"),
url: router.resolve({ name: "Demo" }).href,
},
{
label: t("Contact"),
url: "/contact",
},
{
key: "language_selector",
label: currentLanguageFromList.originalName,
items: languageItems,
},
])
const platformConfigStore = usePlatformConfig()
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))

const menuItems = computed(() => {
const items = [
{
label: t("Home"),
url: router.resolve({ name: "Index" }).href,
},
{
label: t("FAQ"),
url: router.resolve({ name: "Faq" }).href,
},
{
label: t("Demo"),
url: router.resolve({ name: "Demo" }).href,
},
{
label: t("Contact"),
url: "/contact",
},
{
key: "language_selector",
label: currentLanguageFromList.originalName,
items: languageItems,
},
]

if (allowRegistration.value) {
items.splice(2, 0, {
label: t("Registration"),
url: "/main/auth/inscription.php",
})
}

console.log("Menu Items:", items)
return items
})
</script>
3 changes: 3 additions & 0 deletions src/CoreBundle/Controller/PlatformConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function list(SettingsManager $settingsManager): Response
'visual_theme' => $this->themeHelper->getVisualTheme(),
'external_authentication' => $this->authenticationConfigHelper->getEnabledProviders(),
];

$configuration['settings']['registration.allow_registration'] = $settingsManager->getSetting('registration.allow_registration', true);

$variables = [];

if ($this->isGranted('ROLE_USER')) {
Expand Down
7 changes: 6 additions & 1 deletion var/vue_templates/components/SidebarLogin.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script setup>
import { ref } from "vue"
import {computed, ref} from "vue"
import { useI18n } from "vue-i18n"
import InputText from "primevue/inputtext"
import Password from "primevue/password"
import Button from "primevue/button"
import InputSwitch from "primevue/inputswitch"
import { useLogin } from "../../../assets/vue/composables/auth/login"
import {usePlatformConfig} from "../../../assets/vue/store/platformConfig"

const { t } = useI18n()

Expand All @@ -15,6 +16,9 @@ const login = ref("")
const password = ref("")
const remember = ref(false)

const platformConfigStore = usePlatformConfig()
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))

function onSubmitLoginForm() {
performLogin({
login: login.value,
Expand Down Expand Up @@ -74,6 +78,7 @@ function onSubmitLoginForm() {
/>

<a
v-if="allowRegistration"
v-t="'Register oneself'"
class="btn btn--primary-outline"
href="/main/auth/inscription.php"
Expand Down
74 changes: 43 additions & 31 deletions var/vue_templates/components/layout/SidebarNotLoggedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Dropdown from "primevue/dropdown"
import SidebarLogin from "../SidebarLogin.vue"
import PageList from "../../../../assets/vue/components/page/PageList.vue"
import { useLocale } from "../../../../assets/vue/composables/locale"
import { usePlatformConfig } from "../../../../assets/vue/store/platformConfig"

const { t } = useI18n()
const router = useRouter()
Expand All @@ -22,37 +23,48 @@ const languageItems = languageList.map((language) => ({
isoCode: language.isocode,
}))

const menuItems = computed(() => [
{
label: t("Home"),
url: router.resolve({ name: "Index" }).href,
},
{
id: "login-header-item",
label: t("Login"),
items: [
{
id: "login-form-item",
},
],
},
{
label: t("Registration"),
url: "/main/auth/inscription.php",
},
{
label: t("Demo"),
url: router.resolve({ name: "Demo" }).href,
},
{
label: t("FAQ"),
url: router.resolve({ name: "Faq" }).href,
},
{
label: t("Contact"),
url: "/contact",
},
])
const platformConfigStore = usePlatformConfig()
const allowRegistration = computed(() => "false" !== platformConfigStore.getSetting("registration.allow_registration"))


const menuItems = computed(() => {
const items = [
{
label: t("Home"),
url: router.resolve({ name: "Index" }).href,
},
{
id: "login-header-item",
label: t("Login"),
items: [
{
id: "login-form-item",
},
],
},
{
label: t("Demo"),
url: router.resolve({ name: "Demo" }).href,
},
{
label: t("FAQ"),
url: router.resolve({ name: "Faq" }).href,
},
{
label: t("Contact"),
url: "/contact",
},
]

if (allowRegistration.value) {
items.splice(2, 0, {
label: t("Registration"),
url: "/main/auth/inscription.php",
})
}

return items
})

const sidebarIsOpen = ref(window.localStorage.getItem("sidebarIsOpen") === "true")

Expand Down
Loading