Skip to content

Beautiful Open-Source Form Builder

Refactor OAuthController and enhance user data handling

Julien Nahum2393cfec35bf
diff --git a/api/app/Http/Controllers/Auth/OAuthController.php b/api/app/Http/Controllers/Auth/OAuthController.php
index 1c05edab4..9347a33d6 100644
--- a/api/app/Http/Controllers/Auth/OAuthController.php
+++ b/api/app/Http/Controllers/Auth/OAuthController.php
@@ -23,8 +23,7 @@ class OAuthController extends Controller
public function __construct(
private OAuthUserService $oauthUserService,
private OAuthProviderServiceClass $oauthProviderService
- ) {
- }
+ ) {}
/**
* Redirect the user to the provider authentication page.
@@ -174,7 +173,7 @@ class OAuthController extends Controller
return [
'id' => $socialiteUser->getId(),
- 'name' => $socialiteUser->getName(),
+ 'name' => $socialiteUser->getName() ?? $socialiteUser->getNickname(),
'email' => $socialiteUser->getEmail(),
'provider_user_id' => $socialiteUser->getId(),
'access_token' => $socialiteUser->token,
diff --git a/api/app/Integrations/OAuth/Drivers/OAuthStripeDriver.php b/api/app/Integrations/OAuth/Drivers/OAuthStripeDriver.php
index 479628734..86bb28647 100644
--- a/api/app/Integrations/OAuth/Drivers/OAuthStripeDriver.php
+++ b/api/app/Integrations/OAuth/Drivers/OAuthStripeDriver.php
@@ -54,7 +54,7 @@ class OAuthStripeDriver implements OAuthDriver
public function canCreateUser(): bool
{
- return true;
+ return false;
}
public function setRedirectUrl(string $url): OAuthDriver
diff --git a/client/components/dashboard/ScrollableContainer.vue b/client/components/dashboard/ScrollableContainer.vue
index df3f57ee7..110cbda8a 100644
--- a/client/components/dashboard/ScrollableContainer.vue
+++ b/client/components/dashboard/ScrollableContainer.vue
@@ -56,8 +56,7 @@
<script setup>
import VTransition from '@/components/global/transitions/VTransition.vue'
-import { useScroll, useResizeObserver } from '@vueuse/core'
-import { watch, nextTick } from 'vue'
+import { useScroll, useResizeObserver, useMutationObserver } from '@vueuse/core'
const props = defineProps({
maxHeightClass: {
@@ -108,13 +107,38 @@ const contentWidth = ref(0)
const containerWidth = ref(0)
const showTopFade = computed(() => {
- return (props.direction === 'vertical' || props.direction === 'both') && scrollY.value > props.scrollTolerance
+ if (!['vertical', 'both'].includes(props.direction)) return false
+ // ensure reactivity on scroll
+ void scrollY.value
+ // ensure reactivity on size changes
+ void containerHeight.value
+ const element = scrollContainer.value
+ const currentTop = element ? element.scrollTop : 0
+ return currentTop > props.scrollTolerance
})
const showBottomFade = computed(() => {
if (!['vertical', 'both'].includes(props.direction)) return false
- if (containerHeight.value === 0 || contentHeight.value === 0) return false
- return scrollY.value < contentHeight.value - containerHeight.value - props.scrollTolerance
+ // ensure reactivity on scroll
+ void scrollY.value
+ // ensure reactivity on size/content changes
+ void containerHeight.value
+ void contentHeight.value
+ const element = scrollContainer.value
+ if (!element) return false
+
+ const realContainerHeight = element.clientHeight
+ const realContentHeight = element.scrollHeight
+ const realCurrentScroll = element.scrollTop
+ const realMaxScroll = realContentHeight - realContainerHeight
+
+ if (realMaxScroll <= 0) return false
+
+ const effectiveTolerance = Math.max(props.scrollTolerance, 1)
+ const distanceFromEnd = realMaxScroll - realCurrentScroll
+ const isAtEnd = distanceFromEnd <= effectiveTolerance
+
+ return !isAtEnd
})
const showLeftFade = computed(() => {
@@ -128,6 +152,11 @@ const showRightFade = computed(() => {
// Get real-time measurements from the actual element for more accuracy
const element = scrollContainer.value
if (!element) return false
+ // ensure reactivity on scroll
+ void scrollX.value
+ // ensure reactivity on size/content changes
+ void containerWidth.value
+ void contentWidth.value
const realContainerWidth = element.clientWidth // excludes scrollbar, includes padding
const realContentWidth = element.scrollWidth
@@ -237,6 +266,20 @@ watch([contentWidth, contentHeight], () => {
})
})
+// Initialize dimensions once mounted
+onMounted(() => {
+ nextTick(() => updateDimensions())
+})
+
+// Observe slot/content mutations to keep dimensions fresh when content changes
+useMutationObserver(scrollContainer, () => {
+ nextTick(() => updateDimensions())
+}, {
+ childList: true,
+ subtree: true,
+ characterData: true
+})
+
// Expose container ref and utility functions for parent components
defineExpose({
scrollContainer,
diff --git a/client/components/open/forms/fields/components/PaymentFieldOptions.vue b/client/components/open/forms/fields/components/PaymentFieldOptions.vue
index 0e15b433f..0aeabbd8d 100644
--- a/client/components/open/forms/fields/components/PaymentFieldOptions.vue
+++ b/client/components/open/forms/fields/components/PaymentFieldOptions.vue
@@ -77,7 +77,7 @@ const props = defineProps({
const crisp = useCrisp()
const oAuth = useOAuth()
-const { data: providersData, refetch } = oAuth.providers()
+const { data: providersData, refetch} = oAuth.providers()
const stripeLoading = ref(false)
// Setup window message listener for Stripe connection
@@ -109,7 +109,7 @@ onMounted(async () => {
}, {
useMessageChannel: false,
acknowledge: false
- }, `${WindowMessageTypes.OAUTH_PROVIDER_CONNECTED}:stripe`)
+ }, WindowMessageTypes.OAUTH_PROVIDER_CONNECTED)
})
onUnmounted(() => {
diff --git a/client/components/open/tables/components/OpenPayment.vue b/client/components/open/tables/components/OpenPayment.vue
index e933ec268..5b371909c 100644
--- a/client/components/open/tables/components/OpenPayment.vue
+++ b/client/components/open/tables/components/OpenPayment.vue
@@ -6,7 +6,7 @@
<UButton
:to="paymentUrl"
size="xs"
- variant="link"
+ variant="soft"
icon="i-heroicons-credit-card-20-solid"
trailing-icon="i-heroicons-arrow-top-right-on-square-20-solid"
label="Payment"
diff --git a/client/components/users/settings/Connections.vue b/client/components/users/settings/Connections.vue
index 905874a2c..0820bc983 100644
--- a/client/components/users/settings/Connections.vue
+++ b/client/components/users/settings/Connections.vue
@@ -8,17 +8,28 @@
Manage your external connections and integrations.
</p>
</div>
- <UButton
- label="Connect Account"
- icon="i-heroicons-plus"
- :loading="isLoading"
- @click="providerModal = true"
- />
+ <div class="flex items-center gap-2">
+ <UButton
+ icon="i-heroicons-arrow-path"
+ color="neutral"
+ variant="soft"
+ square
+ size="md"
+ :loading="isFetching"
+ @click="refreshProviders"
+ />
+ <UButton
+ label="Connect Account"
+ icon="i-heroicons-plus"
+ :loading="isFetching"
+ @click="providerModal = true"
+ />
+ </div>
</div>
<!-- Providers List -->
<div class="space-y-4">
- <div v-if="providers.length === 0 && !isLoading" class="text-center py-12">
+ <div v-if="providers.length === 0 && !isFetching" class="text-center py-12">
<UIcon
name="i-heroicons-link"
class="w-12 h-12 text-neutral-400 mx-auto mb-4"
@@ -41,7 +52,7 @@
v-model:column-pinning="columnPinning"
:data="providers"
:columns="tableColumns"
- :loading="isLoading"
+ :loading="isFetching"
class="w-full"
>
<template #provider-cell="{ row: { original: item } }">
@@ -93,7 +104,7 @@ const providerModal = ref(false)
const oAuth = useOAuth()
const alert = useAlert()
-const { data: providersData, isLoading: isLoading, refetch } = oAuth.providers()
+const { data: providersData, refetch, isFetching } = oAuth.providers()
const providers = computed(() => providersData.value || [])
// Column pinning state
@@ -148,6 +159,11 @@ const disconnectProvider = (provider) => {
})
}
+// Refresh providers
+const refreshProviders = async () => {
+ await refetch()
+}
+
// Fetch providers on mount
await oAuth.fetchOAuthProviders()
</script>
\ No newline at end of file
diff --git a/client/components/users/settings/Modal.vue b/client/components/users/settings/Modal.vue
index c72c2918f..c9b64c23d 100644
--- a/client/components/users/settings/Modal.vue
+++ b/client/components/users/settings/Modal.vue
@@ -40,7 +40,7 @@
</SettingsModalPage>
<SettingsModalPage
- v-if="user && user.has_customer_id"
+ v-if="user && (user.has_customer_id || user.active_license)"
id="billing"
label="Billing"
icon="i-heroicons-credit-card"
diff --git a/client/composables/query/useOAuth.js b/client/composables/query/useOAuth.js
index 4a582c693..a6dc8883b 100644
--- a/client/composables/query/useOAuth.js
+++ b/client/composables/query/useOAuth.js
@@ -229,19 +229,12 @@ export function useOAuth() {
})
// Utility functions
- const prefetchProviders = () => {
- return queryClient.prefetchQuery({
- queryKey: ['oauth', 'providers'],
- queryFn: () => oauthApi.list()
- })
- }
-
const invalidateProviders = () => {
- queryClient.invalidateQueries(['oauth', 'providers'])
+ queryClient.invalidateQueries({ queryKey: ['oauth', 'providers'] })
}
const invalidateProvider = (providerId) => {
- queryClient.invalidateQueries(['oauth', 'providers', providerId])
+ queryClient.invalidateQueries({ queryKey: ['oauth', 'providers', providerId] })
}
const getProviderByService = (service) => {
@@ -282,7 +275,6 @@ export function useOAuth() {
redirect,
// Utilities
- prefetchProviders,
invalidateProviders,
invalidateProvider,
getProviderByService