Enhance authentication flow: Add authentication-based buttons in AppNavigation for logged-in users, improve member status checks in useAuth, and update join page to automatically redirect to the dashboard after registration. Adjust cookie settings for better development experience.

This commit is contained in:
Jennie Robinson Faber 2025-09-03 16:55:01 +01:00
parent 2ca290d6e0
commit 600fef2b7c
11 changed files with 347 additions and 25 deletions

View file

@ -277,17 +277,23 @@
</dl>
</div>
<p class="text-gray-600 dark:text-gray-400 mb-8">
<p class="text-gray-600 dark:text-gray-400 mb-4">
We've sent a confirmation email to {{ form.email }} with your membership details.
</p>
<div class="bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 mb-8">
<p class="text-blue-800 dark:text-blue-200 text-center">
You will be automatically redirected to your dashboard in a few seconds...
</p>
</div>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<UButton
to="/member/dashboard"
size="lg"
class="px-8"
>
Go to Dashboard
Go to Dashboard Now
</UButton>
<UButton
variant="outline"
@ -535,6 +541,7 @@ const contributionOptions = getContributionOptions()
// Initialize composables
const { initializeHelcimPay, verifyPayment, cleanup: cleanupHelcimPay } = useHelcimPay()
const { checkMemberStatus } = useAuth()
// Form validation
const isFormValid = computed(() => {
@ -577,9 +584,8 @@ const handleSubmit = async () => {
customerId.value = response.customerId
customerCode.value = response.customerCode
// Store token in session
const authToken = useCookie('auth-token')
authToken.value = response.token
// Token is now set as httpOnly cookie by the server
// No need to manually set cookie on client side
// Move to next step
if (needsPayment.value) {
@ -591,6 +597,13 @@ const handleSubmit = async () => {
} else {
// For free tier, create subscription directly
await createSubscription()
// Check member status to ensure user is properly authenticated
await checkMemberStatus()
// Automatically redirect to dashboard after a short delay
setTimeout(() => {
navigateTo('/member/dashboard')
}, 3000) // 3 second delay to show success message
}
}
} catch (error) {
@ -681,6 +694,14 @@ const createSubscription = async (cardToken = null) => {
console.log('Moving to step 3 - success!')
currentStep.value = 3
successMessage.value = 'Your membership has been activated successfully!'
// Check member status to ensure user is properly authenticated
await checkMemberStatus()
// Automatically redirect to dashboard after a short delay
setTimeout(() => {
navigateTo('/member/dashboard')
}, 3000) // 3 second delay to show success message
} else {
throw new Error('Subscription creation failed - response not successful')
}