sigh
This commit is contained in:
parent
f117b6295b
commit
633d830a10
@ -1,18 +0,0 @@
|
|||||||
import { createClient } from '@/lib/supabase/server'
|
|
||||||
import { NextResponse } from 'next/server'
|
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
|
||||||
const { searchParams, origin } = new URL(request.url)
|
|
||||||
const code = searchParams.get('code')
|
|
||||||
const next = searchParams.get('next') ?? '/'
|
|
||||||
|
|
||||||
if (code) {
|
|
||||||
const supabase = createClient()
|
|
||||||
const { error } = await supabase.auth.exchangeCodeForSession(code)
|
|
||||||
if (!error) {
|
|
||||||
return NextResponse.redirect(`${origin}${next}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NextResponse.redirect(`${origin}/auth/auth-code-error`)
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import { createClient } from '@/lib/supabase/client'
|
|
||||||
import { Button } from './ui/button'
|
|
||||||
import { LogIn, LogOut, User } from 'lucide-react'
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu"
|
|
||||||
|
|
||||||
export function AuthButton({ user }: { user: any }) {
|
|
||||||
const supabase = createClient()
|
|
||||||
|
|
||||||
const handleSignIn = async () => {
|
|
||||||
await supabase.auth.signInWithOAuth({
|
|
||||||
provider: 'vatsim',
|
|
||||||
options: {
|
|
||||||
redirectTo: `${location.origin}/auth/callback`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
|
||||||
await supabase.auth.signOut()
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user) {
|
|
||||||
return (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" className="gap-2">
|
|
||||||
<User className="h-4 w-4" />
|
|
||||||
{user.user_metadata?.full_name || 'User'}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuLabel>Account</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem onClick={handleSignOut}>
|
|
||||||
<LogOut className="h-4 w-4 mr-2" />
|
|
||||||
Sign Out
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button onClick={handleSignIn} className="gap-2">
|
|
||||||
<LogIn className="h-4 w-4" />
|
|
||||||
Sign in with VATSIM
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user