-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ adding sign in feature for new users
- Loading branch information
Showing
18 changed files
with
461 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client'; | ||
|
||
export default function DashboardPage() { | ||
return ( | ||
<div className='container mx-auto py-8'> | ||
<h1 className='text-3xl font-bold'>Dashboard</h1> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NavBar } from '@ultra-reporter/ui/home/nav-bar'; | ||
|
||
export default function AuthLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<> | ||
<NavBar hideAuth={true} /> | ||
{children} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use client'; | ||
|
||
import { Button } from '@ultra-reporter/ui/components/button'; | ||
import { DemoCarousel } from '@ultra-reporter/ui/components/demo-carousel'; | ||
import { Icons } from '@ultra-reporter/ui/components/icons'; | ||
import { useState } from 'react'; | ||
|
||
export default function AuthPage() { | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
const handleAuth = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await fetch('/api/auth/login', { | ||
method: 'POST', | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Authentication failed'); | ||
} | ||
|
||
const data = await response.json(); | ||
|
||
if (data.url) { | ||
window.location.href = data.url; | ||
} else { | ||
throw new Error('No OAuth URL received'); | ||
} | ||
} catch (error) { | ||
console.error('Authentication error:', error); | ||
// You might want to show an error message to the user here | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className='container mx-auto flex min-h-screen items-center justify-center'> | ||
<div className='grid w-full items-center gap-8 lg:grid-cols-2'> | ||
{/* Demo Carousel Section */} | ||
<div className='relative hidden h-[600px] lg:block'> | ||
<DemoCarousel /> | ||
</div> | ||
|
||
{/* Auth Section */} | ||
<div className='mx-auto w-full max-w-md space-y-8'> | ||
<div className='space-y-2 text-center'> | ||
<h1 className='text-3xl font-bold tracking-tight'> | ||
Welcome to Ultra Reporter | ||
</h1> | ||
<p className='text-muted-foreground text-lg'> | ||
Sign in to your account or create a new one | ||
</p> | ||
</div> | ||
|
||
<div className='space-y-4'> | ||
<Button | ||
variant='default' | ||
size='lg' | ||
className='w-full py-6 text-lg' | ||
onClick={handleAuth} | ||
disabled={isLoading} | ||
> | ||
{isLoading && ( | ||
<Icons.spinner className='mr-2 h-5 w-5 animate-spin' /> | ||
)} | ||
<Icons.google className='mr-2 h-5 w-5' /> | ||
Continue with Google | ||
</Button> | ||
|
||
<div className='relative'> | ||
<div className='absolute inset-0 flex items-center'> | ||
<span className='w-full border-t' /> | ||
</div> | ||
<div className='relative flex justify-center text-sm uppercase'> | ||
<span className='bg-background text-muted-foreground px-2'> | ||
Secure Authentication | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<p className='text-muted-foreground text-center text-sm'> | ||
By continuing, you agree to our{' '} | ||
<a href='/terms' className='hover:text-primary underline'> | ||
Terms of Service | ||
</a>{' '} | ||
and{' '} | ||
<a href='/privacy' className='hover:text-primary underline'> | ||
Privacy Policy | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { logger } from '@ultra-reporter/logger'; | ||
import { createClient } from '@ultra-reporter/supabase/server'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function POST(req: Request) { | ||
try { | ||
const supabase = await createClient(); | ||
const origin = req.headers.get('origin') || 'http://localhost:3000'; | ||
|
||
// Get the URL for Google OAuth sign-in | ||
const { data, error } = await supabase.auth.signInWithOAuth({ | ||
provider: 'google', | ||
options: { | ||
redirectTo: `${origin}/auth/callback`, | ||
queryParams: { | ||
access_type: 'offline', | ||
prompt: 'consent', | ||
}, | ||
scopes: 'email profile', | ||
}, | ||
}); | ||
|
||
if (error) { | ||
logger.error('OAuth initialization failed', { error }); | ||
return NextResponse.json( | ||
{ error: 'Failed to start OAuth flow' }, | ||
{ status: 500 } | ||
); | ||
} | ||
|
||
if (!data.url) { | ||
logger.error('No OAuth URL returned'); | ||
return NextResponse.json( | ||
{ error: 'Invalid OAuth configuration' }, | ||
{ status: 500 } | ||
); | ||
} | ||
|
||
logger.info('OAuth flow initiated', { url: data.url }); | ||
return NextResponse.json({ url: data.url }, { status: 200 }); | ||
} catch (error) { | ||
logger.error('Unexpected error during OAuth initialization', { error }); | ||
return NextResponse.json( | ||
{ error: 'Internal server error' }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { updateSession } from '@ultra-reporter/supabase/middleware'; | ||
import { type NextRequest } from 'next/server'; | ||
|
||
export async function middleware(request: NextRequest) { | ||
return await updateSession(request); | ||
} | ||
|
||
export const config = { | ||
matcher: [ | ||
/* | ||
* Match all request paths except: | ||
* - _next/static (static files) | ||
* - _next/image (image optimization files) | ||
* - favicon.ico (favicon file) | ||
* - images - .svg, .png, .jpg, .jpeg, .gif, .webp | ||
* Feel free to modify this pattern to include more paths. | ||
*/ | ||
'/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.