fix(landing): show workflows for users that have been approved & logged in

This commit is contained in:
Waleed Latif
2025-04-10 12:52:37 -07:00
parent ae626dbbe0
commit 32bded7da8
5 changed files with 67 additions and 2 deletions

View File

@@ -30,6 +30,11 @@ export function SocialLoginButtons({
setIsGithubLoading(true)
try {
await client.signIn.social({ provider: 'github', callbackURL })
// Mark that the user has previously logged in
if (typeof window !== 'undefined') {
localStorage.setItem('has_logged_in_before', 'true')
}
} catch (err: any) {
let errorMessage = 'Failed to sign in with GitHub'
@@ -55,6 +60,11 @@ export function SocialLoginButtons({
setIsGoogleLoading(true)
try {
await client.signIn.social({ provider: 'google', callbackURL })
// Mark that the user has previously logged in
if (typeof window !== 'undefined') {
localStorage.setItem('has_logged_in_before', 'true')
}
} catch (err: any) {
let errorMessage = 'Failed to sign in with Google'

View File

@@ -118,6 +118,11 @@ export default function LoginPage({
setIsLoading(false)
return
}
// Mark that the user has previously logged in
if (typeof window !== 'undefined') {
localStorage.setItem('has_logged_in_before', 'true')
}
} catch (err: any) {
// Handle only the special verification case that requires a redirect
if (err.message?.includes('not verified') || err.message?.includes('EMAIL_NOT_VERIFIED')) {

View File

@@ -165,6 +165,16 @@ export function VerifyContent({ hasResendKey, baseUrl, isProduction }: VerifyCon
<Suspense fallback={<VerificationFormFallback />}>
<VerificationForm hasResendKey={hasResendKey} isProduction={isProduction} />
</Suspense>
{/* Login link for already verified users */}
<CardFooter className="flex justify-center pt-0">
<p className="text-sm text-muted-foreground">
Already have an account? Go to{' '}
<a href="/login" className="text-primary hover:underline font-medium">
Login
</a>
</p>
</CardFooter>
</Card>
)
}

View File

@@ -1,7 +1,14 @@
'use client'
import { useEffect, useState } from 'react'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { useSession } from '@/lib/auth-client'
import { createLogger } from '@/lib/logs/console-logger'
import { useWindowSize } from './use-window-size'
const logger = createLogger('NavClient')
const XIcon = () => (
<svg
data-testid="geist-icon"
@@ -41,14 +48,48 @@ const DiscordIcon = () => (
export default function NavClient({ children }: { children: React.ReactNode }) {
const { width } = useWindowSize()
const isMobile = width !== undefined && width < 640
const { data: session } = useSession()
const isAuthenticated = !!session?.user
const [hasPreviouslyLoggedIn, setHasPreviouslyLoggedIn] = useState(false)
// Check if user has previously logged in
useEffect(() => {
// Check localStorage for previous login flag
if (typeof window !== 'undefined') {
const hasLoggedInBefore = localStorage.getItem('has_logged_in_before') === 'true'
setHasPreviouslyLoggedIn(hasLoggedInBefore)
}
// If user is currently authenticated, set the flag for future visits
if (isAuthenticated && typeof window !== 'undefined') {
localStorage.setItem('has_logged_in_before', 'true')
}
}, [isAuthenticated])
return (
<nav className="fixed top-1 left-0 right-0 z-10 backdrop-blur-sm px-4 py-4">
<div className="max-w-6xl mx-auto flex justify-between items-center">
<div className="text-xl text-white">sim studio</div>
{/* Social media icons */}
{/* Navigation and social media icons */}
<div className={`flex items-center ${isMobile ? 'gap-2' : 'gap-3'}`}>
{isAuthenticated ? (
<Link
href="/w"
className="text-white/80 hover:text-white/100 text-xl p-2 rounded-md hover:scale-[1.04] transition-colors transition-transform duration-200"
>
workflows
</Link>
) : (
hasPreviouslyLoggedIn && (
<Link
href="/login"
className="text-white/80 hover:text-white/100 text-xl p-2 rounded-md hover:scale-[1.04] transition-colors transition-transform duration-200"
>
login
</Link>
)
)}
<a
href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs`}
className="text-white/80 hover:text-white/100 text-xl p-2 rounded-md hover:scale-[1.04] transition-colors transition-transform duration-200"

View File

@@ -26,7 +26,6 @@ export const xAIProvider: ProviderConfig = {
const xai = new OpenAI({
apiKey: request.apiKey,
baseURL: 'https://api.x.ai/v1',
dangerouslyAllowBrowser: true,
})
const allMessages = []