Skip to content

Commit

Permalink
fix: hide social login if no providers are configured
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <galexrt@googlemail.com>
  • Loading branch information
galexrt committed Jan 23, 2025
1 parent c1fba4e commit ee0566c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 99 deletions.
4 changes: 2 additions & 2 deletions app/components/auth/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ function togglePasswordVisibility() {
{{ $t('common.login') }}
</UButton>

<div v-if="!isNUIAvailable" class="space-y-2">
<div v-if="!isNUIAvailable && login.providers.length > 0" class="space-y-2">
<p v-if="!socialLoginEnabled" class="text-sm text-error-400">
{{ $t('components.auth.LoginForm.social_login_disabled') }}
</p>

<template v-else-if="login.providers.length > 0">
<template v-else>
<UDivider :label="$t('common.or')" orientation="horizontal" class="mt-2" />

<div v-for="provider in login.providers" :key="provider.name">
Expand Down
2 changes: 1 addition & 1 deletion app/components/auth/RegistrationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const onSubmitThrottle = useThrottleFn(async (event: FormSubmitEvent<Schema>) =>
</UForm>

<div class="mt-6">
<UButton block color="gray" :to="{ name: 'auth-login' }" :disabled="!canSubmit">
<UButton block color="gray" trailing-icon="i-mdi-login" :to="{ name: 'auth-login' }" :disabled="!canSubmit">
{{ $t('components.auth.RegistrationForm.back_to_login_button') }}
</UButton>
</div>
Expand Down
36 changes: 20 additions & 16 deletions app/components/auth/account/AccountInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,30 @@ async function removeOAuth2Connection(provider: string): Promise<void> {
}
}
const items = [
{
slot: 'accountInfo',
label: t('components.auth.AccountInfo.title'),
icon: 'i-mdi-information-slab-circle',
},
{
slot: 'oauth2Connections',
label: t('components.auth.OAuth2Connections.title'),
icon: 'i-simple-icons-discord',
},
{ slot: 'debugInfo', label: t('components.debug_info.title'), icon: 'i-mdi-connection' },
];
const items = computed(() =>
[
{
slot: 'accountInfo',
label: t('components.auth.AccountInfo.title'),
icon: 'i-mdi-information-slab-circle',
},
account.value?.oauth2Providers && account.value.oauth2Providers.length > 0
? {
slot: 'oauth2Connections',
label: t('components.auth.OAuth2Connections.title'),
icon: 'i-simple-icons-discord',
}
: undefined,
{ slot: 'debugInfo', label: t('components.debug_info.title'), icon: 'i-mdi-connection' },
].flatMap((item) => (item !== undefined ? [item] : [])),
);
const route = useRoute();
const router = useRouter();
const selectedTab = computed({
get() {
const index = items.findIndex((item) => item.slot === route.query.tab);
const index = items.value.findIndex((item) => item.slot === route.query.tab);
if (index === -1) {
return 0;
}
Expand All @@ -67,7 +71,7 @@ const selectedTab = computed({
},
set(value) {
// Hash is specified here to prevent the page from scrolling to the top
router.replace({ query: { tab: items[value]?.slot }, hash: '#' });
router.replace({ query: { tab: items.value[value]?.slot }, hash: '#' });
},
});
</script>
Expand Down Expand Up @@ -155,7 +159,7 @@ const selectedTab = computed({
</UDashboardPanelContent>
</template>

<template #oauth2Connections>
<template v-if="account.oauth2Providers.length > 0" #oauth2Connections>
<OAuth2Connections
:providers="account.oauth2Providers"
:connections="account.oauth2Connections"
Expand Down
8 changes: 7 additions & 1 deletion app/pages/auth/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ const canSubmit = ref(true);
<div v-if="login.signupEnabled" class="space-y-4">
<UDivider orientation="horizontal" />

<UButton block color="gray" :to="{ name: 'auth-registration' }" :disabled="!canSubmit">
<UButton
block
color="gray"
trailing-icon="i-mdi-account-plus"
:to="{ name: 'auth-registration' }"
:disabled="!canSubmit"
>
{{ $t('components.auth.LoginForm.register_account') }}
</UButton>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@types/howler": "2.2.12",
"@types/leaflet": "1.9.16",
"@types/leaflet-contextmenu": "1.4.3",
"@types/node": "22.10.7",
"@types/node": "22.10.9",
"@types/splitpanes": "2.2.6",
"@types/uuid": "10.0.0",
"@types/zxcvbn": "4.4.5",
Expand Down
Loading

0 comments on commit ee0566c

Please sign in to comment.