Refactor secure connection handling in LoginForm component

- Change isSecureConnection from computed to ref and initialize it on component mount.
- Wrap secure connection status messages in ClientOnly to prevent rendering issues during server-side rendering.
This commit is contained in:
Bastian Masanek
2025-10-31 20:05:26 +01:00
parent 75c59d2783
commit f603840f34

View File

@@ -39,8 +39,9 @@ const onSubmit = handleSubmit(async (values) => {
}) })
// Is the connection secure? // Is the connection secure?
const isSecureConnection = computed(() => { const isSecureConnection = ref(false)
return window.location.protocol === 'https:' onMounted(() => {
isSecureConnection.value = window.location.protocol === 'https:'
}) })
</script> </script>
@@ -80,15 +81,17 @@ const isSecureConnection = computed(() => {
{{ isSubmitting ? 'Wird angemeldet...' : 'Anmelden' }} {{ isSubmitting ? 'Wird angemeldet...' : 'Anmelden' }}
</Button> </Button>
<!-- Secure Connection Text --> <ClientOnly>
<p v-if="!isSecureConnection" class="flex items-center justify-center gap-2 text-sm text-white/70"> <!-- Secure Connection Text -->
<ShieldAlert :size="16" class="flex-shrink-0 text-error" /> <p v-if="!isSecureConnection" class="flex items-center justify-center gap-2 text-sm text-white/70">
<span class="text-error">Die Datenübertragung erfolgt NICHT verschlüsselt</span> <ShieldAlert :size="16" class="flex-shrink-0 text-error" />
</p> <span class="text-error">Die Datenübertragung erfolgt NICHT verschlüsselt</span>
<p v-else class="flex items-center justify-center gap-2 text-sm text-white/70"> </p>
<ShieldCheck :size="16" class="flex-shrink-0 text-success" /> <p v-else class="flex items-center justify-center gap-2 text-sm text-white/70">
<span class="text-success">Die Datenübertragung erfolgt verschlüsselt</span> <ShieldCheck :size="16" class="flex-shrink-0 text-success" />
</p> <span class="text-success">Die Datenübertragung erfolgt verschlüsselt</span>
</p>
</ClientOnly>
</form> </form>
</template> </template>